Patch 9.0.1597 Problem: Cursor ends up below the window after a put. Solution: Mark w_crow and w_botline invalid when changing the cursor line. (closes #12465) Files: src/eval.c, src/move.c, src/register.c, src/testdir/test_put.vim, src/testdir/dumps/Test_put_in_last_displayed_line_1.dump
*** ../vim-9.0.1596/src/eval.c 2023-05-19 19:01:13.292413300 +0100 --- src/eval.c 2023-06-01 19:23:13.048692262 +0100 *************** *** 6322,6327 **** --- 6322,6331 ---- if (name[0] == 'w' && dollar_lnum) { + // the "w_valid" flags are not reset when moving the cursor, but they + // do matter for update_topline() and validate_botline(). + check_cursor_moved(curwin); + pos.col = 0; if (name[1] == '0') // "w0": first visible line { *** ../vim-9.0.1596/src/move.c 2023-05-19 14:04:23.133885852 +0100 --- src/move.c 2023-06-01 19:23:33.008570939 +0100 *************** *** 715,733 **** /* * Call this function when the length of the cursor line (in screen * characters) has changed, and the change is before the cursor. * Need to take care of w_botline separately! */ void changed_cline_bef_curs(void) { ! curwin->w_valid &= ~(VALID_WROW|VALID_WCOL|VALID_VIRTCOL |VALID_CHEIGHT|VALID_TOPLINE); } void changed_cline_bef_curs_win(win_T *wp) { ! wp->w_valid &= ~(VALID_WROW|VALID_WCOL|VALID_VIRTCOL |VALID_CHEIGHT|VALID_TOPLINE); } --- 715,735 ---- /* * Call this function when the length of the cursor line (in screen * characters) has changed, and the change is before the cursor. + * If the line length changed the number of screen lines might change, + * requiring updating w_topline. That may also invalidate w_crow. * Need to take care of w_botline separately! */ void changed_cline_bef_curs(void) { ! curwin->w_valid &= ~(VALID_WROW|VALID_WCOL|VALID_VIRTCOL|VALID_CROW |VALID_CHEIGHT|VALID_TOPLINE); } void changed_cline_bef_curs_win(win_T *wp) { ! wp->w_valid &= ~(VALID_WROW|VALID_WCOL|VALID_VIRTCOL|VALID_CROW |VALID_CHEIGHT|VALID_TOPLINE); } *** ../vim-9.0.1596/src/register.c 2023-05-09 17:09:25.657491200 +0100 --- src/register.c 2023-06-01 19:25:30.523904258 +0100 *************** *** 2098,2103 **** --- 2098,2104 ---- { // make sure curwin->w_virtcol is updated changed_cline_bef_curs(); + invalidate_botline(); curwin->w_cursor.col += (colnr_T)(totlen - 1); } if (VIsual_active) *** ../vim-9.0.1596/src/testdir/test_put.vim 2023-04-22 15:35:08.857815545 +0100 --- src/testdir/test_put.vim 2023-06-01 19:18:06.346953669 +0100 *************** *** 262,266 **** --- 262,284 ---- call StopVimInTerminal(buf) endfunc + func Test_put_in_last_displayed_line() + CheckRunVimInTerminal + + let lines =<< trim END + vim9script + autocmd CursorMoved * eval line('w$') + @a = 'x'->repeat(&columns * 2 - 2) + range(&lines)->setline(1) + feedkeys('G"ap') + END + call writefile(lines, 'Xtest_put_last_line', 'D') + let buf = RunVimInTerminal('-S Xtest_put_last_line', #{rows: 10}) + + call VerifyScreenDump(buf, 'Test_put_in_last_displayed_line_1', {}) + + call StopVimInTerminal(buf) + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-9.0.1596/src/testdir/dumps/Test_put_in_last_displayed_line_1.dump 2023-06-01 19:25:52.255789000 +0100 --- src/testdir/dumps/Test_put_in_last_displayed_line_1.dump 2023-06-01 19:18:54.082543033 +0100 *************** *** 0 **** --- 1,10 ---- + |2+0&#ffffff0| @73 + |3| @73 + |4| @73 + |5| @73 + |6| @73 + |7| @73 + |8| @73 + |9|x@73 + @73>x| + @57|1|0|,|1|4|9| @7|B|o|t| *** ../vim-9.0.1596/src/version.c 2023-06-01 12:45:15.875667908 +0100 --- src/version.c 2023-06-01 19:18:40.114660538 +0100 *************** *** 697,698 **** --- 697,700 ---- { /* Add new patch number below this line */ + /**/ + 1597, /**/ -- >From "know your smileys": :-| :-| Deja' vu! /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org /// -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/20230601183145.393D61C05B6%40moolenaar.net.