mirror of
https://github.com/vim/vim.git
synced 2025-09-28 04:24:06 -04:00
patch 9.0.1597: cursor ends up below the window after a put
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)
This commit is contained in:
@@ -6322,6 +6322,10 @@ var2fpos(
|
|||||||
|
|
||||||
if (name[0] == 'w' && dollar_lnum)
|
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;
|
pos.col = 0;
|
||||||
if (name[1] == '0') // "w0": first visible line
|
if (name[1] == '0') // "w0": first visible line
|
||||||
{
|
{
|
||||||
|
@@ -715,19 +715,21 @@ set_topline(win_T *wp, linenr_T lnum)
|
|||||||
/*
|
/*
|
||||||
* Call this function when the length of the cursor line (in screen
|
* Call this function when the length of the cursor line (in screen
|
||||||
* characters) has changed, and the change is before the cursor.
|
* 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!
|
* Need to take care of w_botline separately!
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
changed_cline_bef_curs(void)
|
changed_cline_bef_curs(void)
|
||||||
{
|
{
|
||||||
curwin->w_valid &= ~(VALID_WROW|VALID_WCOL|VALID_VIRTCOL
|
curwin->w_valid &= ~(VALID_WROW|VALID_WCOL|VALID_VIRTCOL|VALID_CROW
|
||||||
|VALID_CHEIGHT|VALID_TOPLINE);
|
|VALID_CHEIGHT|VALID_TOPLINE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
changed_cline_bef_curs_win(win_T *wp)
|
changed_cline_bef_curs_win(win_T *wp)
|
||||||
{
|
{
|
||||||
wp->w_valid &= ~(VALID_WROW|VALID_WCOL|VALID_VIRTCOL
|
wp->w_valid &= ~(VALID_WROW|VALID_WCOL|VALID_VIRTCOL|VALID_CROW
|
||||||
|VALID_CHEIGHT|VALID_TOPLINE);
|
|VALID_CHEIGHT|VALID_TOPLINE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -2098,6 +2098,7 @@ do_put(
|
|||||||
{
|
{
|
||||||
// make sure curwin->w_virtcol is updated
|
// make sure curwin->w_virtcol is updated
|
||||||
changed_cline_bef_curs();
|
changed_cline_bef_curs();
|
||||||
|
invalidate_botline();
|
||||||
curwin->w_cursor.col += (colnr_T)(totlen - 1);
|
curwin->w_cursor.col += (colnr_T)(totlen - 1);
|
||||||
}
|
}
|
||||||
if (VIsual_active)
|
if (VIsual_active)
|
||||||
|
10
src/testdir/dumps/Test_put_in_last_displayed_line_1.dump
Normal file
10
src/testdir/dumps/Test_put_in_last_displayed_line_1.dump
Normal file
@@ -0,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|
|
@@ -262,5 +262,23 @@ func Test_put_other_window()
|
|||||||
call VerifyScreenDump(buf, 'Test_put_other_window_1', {})
|
call VerifyScreenDump(buf, 'Test_put_other_window_1', {})
|
||||||
|
|
||||||
call StopVimInTerminal(buf)
|
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
|
endfunc
|
||||||
|
|
||||||
|
@@ -695,6 +695,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1597,
|
||||||
/**/
|
/**/
|
||||||
1596,
|
1596,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user