mirror of
https://github.com/vim/vim.git
synced 2025-11-16 23:24:03 -05:00
patch 9.1.1888: Wrong display with cpo+=$, matchparen and wrapped line
Problem: Wrong display with cpo+=$, matchparen and wrapped line.
Solution: Use old cursor line height when scrolling with cpo+=$. Also
fix wrong redraw in non-current window. (zeertzjq)
fixes: #18647
closes: #18662
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
14e7203713
commit
5c3e762631
@@ -2280,13 +2280,12 @@ win_update(win_T *wp)
|
||||
// When at start of changed lines: May scroll following lines
|
||||
// up or down to minimize redrawing.
|
||||
// Don't do this when the change continues until the end.
|
||||
// Don't scroll when dollar_vcol >= 0, keep the "$".
|
||||
// Don't scroll when redrawing the top, scrolled already above.
|
||||
if (lnum == mod_top
|
||||
&& mod_bot != MAXLNUM
|
||||
&& !(dollar_vcol >= 0 && mod_bot == mod_top + 1)
|
||||
&& row >= top_end)
|
||||
{
|
||||
int old_cline_height = 0;
|
||||
int old_rows = 0;
|
||||
int new_rows = 0;
|
||||
int xtra_rows;
|
||||
@@ -2302,6 +2301,8 @@ win_update(win_T *wp)
|
||||
if (wp->w_lines[i].wl_valid
|
||||
&& wp->w_lines[i].wl_lnum == mod_bot)
|
||||
break;
|
||||
if (wp->w_lines[i].wl_lnum == wp->w_cursor.lnum)
|
||||
old_cline_height = wp->w_lines[i].wl_size;
|
||||
old_rows += wp->w_lines[i].wl_size;
|
||||
#ifdef FEAT_FOLDING
|
||||
if (wp->w_lines[i].wl_valid
|
||||
@@ -2332,11 +2333,16 @@ win_update(win_T *wp)
|
||||
j = idx;
|
||||
for (l = lnum; l < mod_bot; ++l)
|
||||
{
|
||||
if (dollar_vcol >= 0 && wp == curwin &&
|
||||
old_cline_height > 0 && l == wp->w_cursor.lnum)
|
||||
// When dollar_vcol >= 0, cursor line isn't fully
|
||||
// redrawn, and its height remains unchanged.
|
||||
new_rows += old_cline_height;
|
||||
#ifdef FEAT_FOLDING
|
||||
if (hasFoldingWin(wp, l, NULL, &l, TRUE, NULL))
|
||||
else if (hasFoldingWin(wp, l, NULL, &l, TRUE, NULL))
|
||||
++new_rows;
|
||||
else
|
||||
#endif
|
||||
else
|
||||
new_rows += plines_correct_topline(wp, l, TRUE);
|
||||
++j;
|
||||
if (new_rows > wp->w_height - row - 2)
|
||||
@@ -2504,18 +2510,20 @@ win_update(win_T *wp)
|
||||
wp->w_lines[idx].wl_lnum = lnum;
|
||||
wp->w_lines[idx].wl_valid = TRUE;
|
||||
|
||||
int is_curline = wp == curwin && lnum == wp->w_cursor.lnum;
|
||||
|
||||
// Past end of the window or end of the screen. Note that after
|
||||
// resizing wp->w_height may be end up too big. That's a problem
|
||||
// elsewhere, but prevent a crash here.
|
||||
if (row > wp->w_height || row + wp->w_winrow >= Rows)
|
||||
{
|
||||
// we may need the size of that too long line later on
|
||||
if (dollar_vcol == -1)
|
||||
if (dollar_vcol == -1 || !is_curline)
|
||||
wp->w_lines[idx].wl_size = plines_win(wp, lnum, TRUE);
|
||||
++idx;
|
||||
break;
|
||||
}
|
||||
if (dollar_vcol == -1)
|
||||
if (dollar_vcol == -1 || !is_curline)
|
||||
wp->w_lines[idx].wl_size = row - srow;
|
||||
++idx;
|
||||
#ifdef FEAT_FOLDING
|
||||
@@ -2706,7 +2714,7 @@ win_update(win_T *wp)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else if (dollar_vcol == -1)
|
||||
else if (dollar_vcol == -1 || wp != curwin)
|
||||
wp->w_botline = lnum;
|
||||
|
||||
// Make sure the rest of the screen is blank.
|
||||
@@ -2731,7 +2739,7 @@ win_update(win_T *wp)
|
||||
wp->w_old_botfill = wp->w_botfill;
|
||||
#endif
|
||||
|
||||
if (dollar_vcol == -1)
|
||||
if (dollar_vcol == -1 || wp != curwin)
|
||||
{
|
||||
// There is a trick with w_botline. If we invalidate it on each
|
||||
// change that might modify it, this will cause a lot of expensive
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
|f+0&#ffffff0|o@1| @18||+1&&|f+0&&|o@1| @18
|
||||
|b|a|r| @18||+1&&|b+0&&|a|r| @18
|
||||
>x@21||+1&&|x+0&&@21
|
||||
@3|!@1|(|)|!@1|y@12||+1&&|x+0&&@2|!@1|(|)|!@1|y@12
|
||||
@12| @9||+1&&|y+0&&@11| @9
|
||||
|F|O@1| @18||+1&&|F+0&&|O@1| @18
|
||||
|B|A|R| @18||+1&&|B+0&&|A|R| @18
|
||||
|~+0#4040ff13&| @20||+1#0000000&|~+0#4040ff13&| @20
|
||||
|~| @20||+1#0000000&|~+0#4040ff13&| @20
|
||||
| +0#0000000&@26|3|,|1| @10|A|l@1|
|
||||
@@ -0,0 +1,10 @@
|
||||
|f+0&#ffffff0|o@1| @18||+1&&|f+0&&|o@1| @18
|
||||
|b|a|r| @18||+1&&|b+0&&|a|r| @18
|
||||
>x@21||+1&&|!+0&&@1|(|)|!@1|y@15
|
||||
|x@1|$|!@1|(|)|!@1|y@12||+1&&|y+0&&@8| @12
|
||||
|y@11| @9||+1&&|F+0&&|O@1| @18
|
||||
|F|O@1| @18||+1&&|B+0&&|A|R| @18
|
||||
|B|A|R| @18||+1&&|~+0#4040ff13&| @20
|
||||
|~| @20||+1#0000000&|~+0#4040ff13&| @20
|
||||
|~| @20||+1#0000000&|~+0#4040ff13&| @20
|
||||
|-+2#0000000&@1| |I|N|S|E|R|T| |-@1| +0&&@14|1|,|1| @10|A|l@1|
|
||||
@@ -0,0 +1,10 @@
|
||||
|z+0&#ffffff0@21||+1&&|z+0&&@21
|
||||
@8| @13||+1&&|z+0&&@7| @13
|
||||
|b|a|r| @18||+1&&|b+0&&|a|r| @18
|
||||
>x@21||+1&&|!+0&&@1|(|)|!@1|y@15
|
||||
|x@1|$|!@1|(|)|!@1|y@12||+1&&|y+0&&@8| @12
|
||||
|y@11| @9||+1&&|F+0&&|O@1| @18
|
||||
|F|O@1| @18||+1&&|B+0&&|A|R| @18
|
||||
|B|A|R| @18||+1&&|~+0#4040ff13&| @20
|
||||
|~| @20||+1#0000000&|~+0#4040ff13&| @20
|
||||
|-+2#0000000&@1| |I|N|S|E|R|T| |-@1| +0&&@14|1|,|1| @10|A|l@1|
|
||||
@@ -0,0 +1,10 @@
|
||||
|f+0&#ffffff0|o@1| @18||+1&&|f+0&&|o@1| @18
|
||||
|b|a|r| @18||+1&&|b+0&&|a|r| @18
|
||||
|y>x@20||+1&&|y+0&&|!@1|(|)|!@1|y@14
|
||||
|x@1|$|!@1|(|)|!@1|y@12||+1&&|y+0&&@9| @11
|
||||
|y@11| @9||+1&&|F+0&&|O@1| @18
|
||||
|F|O@1| @18||+1&&|B+0&&|A|R| @18
|
||||
|B|A|R| @18||+1&&|~+0#4040ff13&| @20
|
||||
|~| @20||+1#0000000&|~+0#4040ff13&| @20
|
||||
|~| @20||+1#0000000&|~+0#4040ff13&| @20
|
||||
|-+2#0000000&@1| |I|N|S|E|R|T| |-@1| +0&&@14|3|,|2| @10|A|l@1|
|
||||
@@ -0,0 +1,10 @@
|
||||
|f+0&#ffffff0|o@1| @18||+1&&|f+0&&|o@1| @18
|
||||
|b|a|r| @18||+1&&|b+0&&|a|r| @18
|
||||
|y@1>x@19||+1&&|y+0&&@1|!@1|(|)|!@1|y@13
|
||||
|x@1|$|!@1|(|)|!@1|y@12||+1&&|y+0&&@10| @10
|
||||
|y@11| @9||+1&&|F+0&&|O@1| @18
|
||||
|F|O@1| @18||+1&&|B+0&&|A|R| @18
|
||||
|B|A|R| @18||+1&&|~+0#4040ff13&| @20
|
||||
|~| @20||+1#0000000&|~+0#4040ff13&| @20
|
||||
|~| @20||+1#0000000&|~+0#4040ff13&| @20
|
||||
|-+2#0000000&@1| |I|N|S|E|R|T| |-@1| +0&&@14|3|,|3| @10|A|l@1|
|
||||
@@ -0,0 +1,10 @@
|
||||
|f+0&#ffffff0|o@1| @18||+1&&|f+0&&|o@1| @18
|
||||
|b|a|r| @18||+1&&|b+0&&|a|r| @18
|
||||
|y>y|!@1|(|)|!@1|y@13||+1&&|y+0&&@1|!@1|(|)|!@1|y@13
|
||||
@11| @10||+1&&|y+0&&@10| @10
|
||||
|F|O@1| @18||+1&&|F+0&&|O@1| @18
|
||||
|B|A|R| @18||+1&&|B+0&&|A|R| @18
|
||||
|~+0#4040ff13&| @20||+1#0000000&|~+0#4040ff13&| @20
|
||||
|~| @20||+1#0000000&|~+0#4040ff13&| @20
|
||||
|~| @20||+1#0000000&|~+0#4040ff13&| @20
|
||||
| +0#0000000&@26|3|,|2| @10|A|l@1|
|
||||
@@ -0,0 +1,10 @@
|
||||
|f+0&#ffffff0|o@1| @18||+1&&|f+0&&|o@1| @18
|
||||
|b|a|r| @18||+1&&|b+0&&|a|r| @18
|
||||
>x@21||+1&&|(+0&&|)|!@1|y@17
|
||||
|x@2|!|$|(|)|!@1|y@12||+1&&|y+0&&@6| @14
|
||||
|y@11| @9||+1&&|F+0&&|O@1| @18
|
||||
|F|O@1| @18||+1&&|B+0&&|A|R| @18
|
||||
|B|A|R| @18||+1&&|~+0#4040ff13&| @20
|
||||
|~| @20||+1#0000000&|~+0#4040ff13&| @20
|
||||
|~| @20||+1#0000000&|~+0#4040ff13&| @20
|
||||
|-+2#0000000&@1| |I|N|S|E|R|T| |-@1| +0&&@14|1|,|1| @10|A|l@1|
|
||||
@@ -0,0 +1,10 @@
|
||||
|f+0&#ffffff0|o@1| @18||+1&&|f+0&&|o@1| @18
|
||||
|b|a|r| @18||+1&&|b+0&&|a|r| @18
|
||||
|y>x@20||+1&&|y+0&&|(|)|!@1|y@16
|
||||
|x@2|!|$|(|)|!@1|y@12||+1&&|y+0&&@7| @13
|
||||
|y@11| @9||+1&&|F+0&&|O@1| @18
|
||||
|F|O@1| @18||+1&&|B+0&&|A|R| @18
|
||||
|B|A|R| @18||+1&&|~+0#4040ff13&| @20
|
||||
|~| @20||+1#0000000&|~+0#4040ff13&| @20
|
||||
|~| @20||+1#0000000&|~+0#4040ff13&| @20
|
||||
|-+2#0000000&@1| |I|N|S|E|R|T| |-@1| +0&&@14|3|,|2| @10|A|l@1|
|
||||
@@ -0,0 +1,10 @@
|
||||
|f+0&#ffffff0|o@1| @18||+1&&|f+0&&|o@1| @18
|
||||
|b|a|r| @18||+1&&|b+0&&|a|r| @18
|
||||
|y@1>x@19||+1&&|y+0&&@1|(|)|!@1|y@15
|
||||
|x@2|!|$|(|)|!@1|y@12||+1&&|y+0&&@8| @12
|
||||
|y@11| @9||+1&&|F+0&&|O@1| @18
|
||||
|F|O@1| @18||+1&&|B+0&&|A|R| @18
|
||||
|B|A|R| @18||+1&&|~+0#4040ff13&| @20
|
||||
|~| @20||+1#0000000&|~+0#4040ff13&| @20
|
||||
|~| @20||+1#0000000&|~+0#4040ff13&| @20
|
||||
|-+2#0000000&@1| |I|N|S|E|R|T| |-@1| +0&&@14|3|,|3| @10|A|l@1|
|
||||
@@ -0,0 +1,10 @@
|
||||
|f+0&#ffffff0|o@1| @18||+1&&|f+0&&|o@1| @18
|
||||
|b|a|r| @18||+1&&|b+0&&|a|r| @18
|
||||
|y>y|(|)|!@1|y@15||+1&&|y+0&&@1|(|)|!@1|y@15
|
||||
@9| @12||+1&&|y+0&&@8| @12
|
||||
|F|O@1| @18||+1&&|F+0&&|O@1| @18
|
||||
|B|A|R| @18||+1&&|B+0&&|A|R| @18
|
||||
|~+0#4040ff13&| @20||+1#0000000&|~+0#4040ff13&| @20
|
||||
|~| @20||+1#0000000&|~+0#4040ff13&| @20
|
||||
|~| @20||+1#0000000&|~+0#4040ff13&| @20
|
||||
| +0#0000000&@26|3|,|2| @10|A|l@1|
|
||||
@@ -0,0 +1,10 @@
|
||||
|f+0&#ffffff0|o@1| @18||+1&&|f+0&&|o@1| @18
|
||||
|b|a|r| @18||+1&&|b+0&&|a|r| @18
|
||||
>x@21||+1&&|x+0&&@21
|
||||
@3|!@1|(|z@1| @13||+1&&|x+0&&@2|!@1|(|z@1| @13
|
||||
|z@1|)|!@1|y@16||+1&&|z+0&&@1|)|!@1|y@16
|
||||
@8| @13||+1&&|y+0&&@7| @13
|
||||
|F|O@1| @18||+1&&|F+0&&|O@1| @18
|
||||
|B|A|R| @18||+1&&|B+0&&|A|R| @18
|
||||
|~+0#4040ff13&| @20||+1#0000000&|~+0#4040ff13&| @20
|
||||
| +0#0000000&@26|3|,|1| @10|A|l@1|
|
||||
@@ -0,0 +1,10 @@
|
||||
|f+0&#ffffff0|o@1| @18||+1&&|f+0&&|o@1| @18
|
||||
|b|a|r| @18||+1&&|b+0&&|a|r| @18
|
||||
>x@21||+1&&|(+0&&|z@1| @18
|
||||
|x@2|!|$|(|z@1| @13||+1&&|z+0&&@1|)|!@1|y@16
|
||||
|z@1|)|!@1|y@16||+1&&|y+0&&@7| @13
|
||||
|y@7| @13||+1&&|F+0&&|O@1| @18
|
||||
|F|O@1| @18||+1&&|B+0&&|A|R| @18
|
||||
|B|A|R| @18||+1&&|~+0#4040ff13&| @20
|
||||
|~| @20||+1#0000000&|~+0#4040ff13&| @20
|
||||
|-+2#0000000&@1| |I|N|S|E|R|T| |-@1| +0&&@14|1|,|1| @10|A|l@1|
|
||||
@@ -0,0 +1,10 @@
|
||||
|f+0&#ffffff0|o@1| @18||+1&&|f+0&&|o@1| @18
|
||||
|b|a|r| @18||+1&&|b+0&&|a|r| @18
|
||||
|y>x@20||+1&&|y+0&&|(|z@1| @17
|
||||
|x@2|!|$|(|z@1| @13||+1&&|z+0&&@1|)|!@1|y@16
|
||||
|z@1|)|!@1|y@16||+1&&|y+0&&@7| @13
|
||||
|y@7| @13||+1&&|F+0&&|O@1| @18
|
||||
|F|O@1| @18||+1&&|B+0&&|A|R| @18
|
||||
|B|A|R| @18||+1&&|~+0#4040ff13&| @20
|
||||
|~| @20||+1#0000000&|~+0#4040ff13&| @20
|
||||
|-+2#0000000&@1| |I|N|S|E|R|T| |-@1| +0&&@14|3|,|2| @10|A|l@1|
|
||||
@@ -0,0 +1,10 @@
|
||||
|f+0&#ffffff0|o@1| @18||+1&&|f+0&&|o@1| @18
|
||||
|b|a|r| @18||+1&&|b+0&&|a|r| @18
|
||||
|y@1>x@19||+1&&|y+0&&@1|(|z@1| @16
|
||||
|x@2|!|$|(|z@1| @13||+1&&|z+0&&@1|)|!@1|y@16
|
||||
|z@1|)|!@1|y@16||+1&&|y+0&&@7| @13
|
||||
|y@7| @13||+1&&|F+0&&|O@1| @18
|
||||
|F|O@1| @18||+1&&|B+0&&|A|R| @18
|
||||
|B|A|R| @18||+1&&|~+0#4040ff13&| @20
|
||||
|~| @20||+1#0000000&|~+0#4040ff13&| @20
|
||||
|-+2#0000000&@1| |I|N|S|E|R|T| |-@1| +0&&@14|3|,|3| @10|A|l@1|
|
||||
@@ -0,0 +1,10 @@
|
||||
|f+0&#ffffff0|o@1| @18||+1&&|f+0&&|o@1| @18
|
||||
|b|a|r| @18||+1&&|b+0&&|a|r| @18
|
||||
|y>y|(|z@1| @16||+1&&|y+0&&@1|(|z@1| @16
|
||||
|z@1|)|!@1|y@16||+1&&|z+0&&@1|)|!@1|y@16
|
||||
@8| @13||+1&&|y+0&&@7| @13
|
||||
|F|O@1| @18||+1&&|F+0&&|O@1| @18
|
||||
|B|A|R| @18||+1&&|B+0&&|A|R| @18
|
||||
|~+0#4040ff13&| @20||+1#0000000&|~+0#4040ff13&| @20
|
||||
|~| @20||+1#0000000&|~+0#4040ff13&| @20
|
||||
| +0#0000000&@26|3|,|2| @10|A|l@1|
|
||||
@@ -572,4 +572,65 @@ func Test_display_cursor_long_line()
|
||||
call StopVimInTerminal(buf)
|
||||
endfunc
|
||||
|
||||
func Test_change_wrapped_line_cpo_dollar()
|
||||
CheckScreendump
|
||||
|
||||
let lines =<< trim END
|
||||
set cpoptions+=$ laststatus=0
|
||||
call setline(1, ['foo', 'bar',
|
||||
\ repeat('x', 25) .. '!!()!!' .. repeat('y', 25),
|
||||
\ 'FOO', 'BAR'])
|
||||
inoremap <F2> <Cmd>call setline(1, repeat('z', 30))<CR>
|
||||
inoremap <F3> <Cmd>call setline(1, 'foo')<CR>
|
||||
vsplit
|
||||
call cursor(3, 1)
|
||||
END
|
||||
call writefile(lines, 'Xwrapped_cpo_dollar', 'D')
|
||||
let buf = RunVimInTerminal('-S Xwrapped_cpo_dollar', #{rows: 10, cols: 45})
|
||||
|
||||
call VerifyScreenDump(buf, 'Test_change_wrapped_line_cpo_dollar_01', {})
|
||||
call term_sendkeys(buf, 'ct!')
|
||||
call VerifyScreenDump(buf, 'Test_change_wrapped_line_cpo_dollar_02', {})
|
||||
call term_sendkeys(buf, "\<F2>")
|
||||
call VerifyScreenDump(buf, 'Test_change_wrapped_line_cpo_dollar_03', {})
|
||||
call term_sendkeys(buf, "\<F3>")
|
||||
call VerifyScreenDump(buf, 'Test_change_wrapped_line_cpo_dollar_02', {})
|
||||
call term_sendkeys(buf, 'y')
|
||||
call VerifyScreenDump(buf, 'Test_change_wrapped_line_cpo_dollar_04', {})
|
||||
call term_sendkeys(buf, 'y')
|
||||
call VerifyScreenDump(buf, 'Test_change_wrapped_line_cpo_dollar_05', {})
|
||||
call term_sendkeys(buf, "\<Esc>")
|
||||
call TermWait(buf, 50)
|
||||
call VerifyScreenDump(buf, 'Test_change_wrapped_line_cpo_dollar_06', {})
|
||||
|
||||
call term_sendkeys(buf, ":silent undo | echo\<CR>")
|
||||
call VerifyScreenDump(buf, 'Test_change_wrapped_line_cpo_dollar_01', {})
|
||||
call term_sendkeys(buf, ":source samples/matchparen.vim\<CR>")
|
||||
call term_sendkeys(buf, 'ct(')
|
||||
call VerifyScreenDump(buf, 'Test_change_wrapped_line_cpo_dollar_07', {})
|
||||
call term_sendkeys(buf, 'y')
|
||||
call VerifyScreenDump(buf, 'Test_change_wrapped_line_cpo_dollar_08', {})
|
||||
call term_sendkeys(buf, 'y')
|
||||
call VerifyScreenDump(buf, 'Test_change_wrapped_line_cpo_dollar_09', {})
|
||||
call term_sendkeys(buf, "\<Esc>")
|
||||
call TermWait(buf, 50)
|
||||
call VerifyScreenDump(buf, 'Test_change_wrapped_line_cpo_dollar_10', {})
|
||||
|
||||
call term_sendkeys(buf, ":silent undo | echo\<CR>")
|
||||
call VerifyScreenDump(buf, 'Test_change_wrapped_line_cpo_dollar_01', {})
|
||||
call term_sendkeys(buf, "f(azz\<CR>zz\<Esc>k0")
|
||||
call VerifyScreenDump(buf, 'Test_change_wrapped_line_cpo_dollar_11', {})
|
||||
call term_sendkeys(buf, 'ct(')
|
||||
call VerifyScreenDump(buf, 'Test_change_wrapped_line_cpo_dollar_12', {})
|
||||
call term_sendkeys(buf, 'y')
|
||||
call VerifyScreenDump(buf, 'Test_change_wrapped_line_cpo_dollar_13', {})
|
||||
call term_sendkeys(buf, 'y')
|
||||
call VerifyScreenDump(buf, 'Test_change_wrapped_line_cpo_dollar_14', {})
|
||||
call term_sendkeys(buf, "\<Esc>")
|
||||
call TermWait(buf, 50)
|
||||
call VerifyScreenDump(buf, 'Test_change_wrapped_line_cpo_dollar_15', {})
|
||||
|
||||
call StopVimInTerminal(buf)
|
||||
endfunc
|
||||
|
||||
" vim: shiftwidth=2 sts=2 expandtab
|
||||
|
||||
@@ -729,6 +729,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
1888,
|
||||
/**/
|
||||
1887,
|
||||
/**/
|
||||
|
||||
Reference in New Issue
Block a user