Skip to content

Commit

Permalink
Remember to still update the cursor position when it's within an enti…
Browse files Browse the repository at this point in the history
…re skipped range of rows at reflow time
  • Loading branch information
leonerd committed May 9, 2023
1 parent 0176230 commit d2e3150
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -595,8 +595,15 @@ static void resize_buffer(VTermScreen *screen, int bufidx, int new_rows, int new
new_row_start, new_row_end, old_row_start, old_row_end, width);
#endif

if(new_row_start < 0)
if(new_row_start < 0) {
if(old_row_start <= old_cursor.row && old_cursor.row < old_row_end) {
new_cursor.row = 0;
new_cursor.col = old_cursor.col;
if(new_cursor.col >= new_cols)
new_cursor.col = new_cols-1;
}
break;
}

for(new_row = new_row_start, old_row = old_row_start; new_row <= new_row_end; new_row++) {
int count = width >= new_cols ? new_cols : width;
Expand Down
9 changes: 9 additions & 0 deletions t/69screen_reflow.test
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,12 @@ RESIZE 5,16
?lineinfo 3 =
?screen_row 3 = "> "
?cursor = 3,2

!Cursor goes missing
# For more context: https://github.com/neovim/neovim/pull/21124
RESET
RESIZE 5,5
RESIZE 3,1
PUSH "\x1b[2;1Habc\r\n\x1b[H"
RESIZE 1,1
?cursor = 0,0

0 comments on commit d2e3150

Please sign in to comment.