Skip to content

Commit 6f1ddf7

Browse files
authored
Fix cursor position when scrolled into history
This fixes a regression introduced in 530de00, where the terminal cursor would move up when the user scrolled up in the terminal history, rather than staying in place. Fixes alacritty#4784.
1 parent fc87aaa commit 6f1ddf7

File tree

1 file changed

+9
-4
lines changed
  • alacritty_terminal/src/term

1 file changed

+9
-4
lines changed

Diff for: alacritty_terminal/src/term/mod.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -1829,14 +1829,19 @@ impl RenderableCursor {
18291829
fn new<T>(term: &Term<T>) -> Self {
18301830
// Cursor position.
18311831
let vi_mode = term.mode().contains(TermMode::VI);
1832-
let point = if vi_mode { term.vi_mode_cursor.point } else { term.grid().cursor.point };
1832+
let mut point = if vi_mode {
1833+
term.vi_mode_cursor.point
1834+
} else {
1835+
let mut point = term.grid.cursor.point;
1836+
point.line += term.grid.display_offset();
1837+
point
1838+
};
18331839

18341840
// Cursor shape.
1835-
let absolute_line = term.screen_lines() - point.line - 1;
1836-
let display_offset = term.grid().display_offset();
18371841
let shape = if !vi_mode
1838-
&& (!term.mode().contains(TermMode::SHOW_CURSOR) || absolute_line.0 < display_offset)
1842+
&& (!term.mode().contains(TermMode::SHOW_CURSOR) || point.line >= term.screen_lines())
18391843
{
1844+
point.line = Line(0);
18401845
CursorShape::Hidden
18411846
} else {
18421847
term.cursor_style().shape

0 commit comments

Comments
 (0)