From d2e3150f6a7d93aff5a15a67762b422ea5d11912 Mon Sep 17 00:00:00 2001 From: "Paul \"LeoNerd\" Evans" Date: Wed, 10 May 2023 00:18:48 +0100 Subject: [PATCH] Remember to still update the cursor position when it's within an entire skipped range of rows at reflow time --- src/screen.c | 9 ++++++++- t/69screen_reflow.test | 9 +++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/screen.c b/src/screen.c index ab281b56..cda63fb3 100644 --- a/src/screen.c +++ b/src/screen.c @@ -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; diff --git a/t/69screen_reflow.test b/t/69screen_reflow.test index 278cc5bd..eb7e4e4d 100644 --- a/t/69screen_reflow.test +++ b/t/69screen_reflow.test @@ -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