Skip to content

Commit c9e7e34

Browse files
committed
patch 8.2.3204: display garbled when 'cursorline' is set and lines wrap
Problem: Display garbled when 'cursorline' is set and lines wrap. (Gabriel Dupras) Solution: Avoid inserting lines twice.
1 parent cd26801 commit c9e7e34

5 files changed

Lines changed: 94 additions & 1 deletion

File tree

src/drawscreen.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2249,9 +2249,11 @@ win_update(win_T *wp)
22492249
// up or down to minimize redrawing.
22502250
// Don't do this when the change continues until the end.
22512251
// Don't scroll when dollar_vcol >= 0, keep the "$".
2252+
// Don't scroll when redrawing the top, scrolled already above.
22522253
if (lnum == mod_top
22532254
&& mod_bot != MAXLNUM
2254-
&& !(dollar_vcol >= 0 && mod_bot == mod_top + 1))
2255+
&& !(dollar_vcol >= 0 && mod_bot == mod_top + 1)
2256+
&& row >= top_end)
22552257
{
22562258
int old_rows = 0;
22572259
int new_rows = 0;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
| +0&#ffffff0@23|o|n|e| |b|y| |o|n|e| |t|o| |a|v
2+
|o|i|d| |p|r|o|b|l|e|m|s|.| @26
3+
@24|A|l|s|o| |s|e@1| |||:|s|e|t|-|a
4+
|r|g|s||| |a|b|o|v|e|.| @28
5+
@40
6+
|T|h|e| |{|o|p|t|i|o|n|}| |a|r|g|u|m|e|n|t|s| |t|o| |"|:|s|e|t|"| |m|a|y| |b|e|
7+
|r|e|p|e|a|t|e|d|.| @1|F|o|r| |e|x|a|m|p|l|e|:| |>| @14
8+
@8|:|s|e|t| |a|i| |n|o|s|i| |s|w|=|3| |t|s|=|3| @9
9+
|I|f| |y|o|u| |m|a|k|e| |a|n| |e|r@1|o|r| |i|n| |o|n|e| |o|f| |t|h|e| |a|r|g|u|m
10+
|e|n|t|s|,| |a|n| |e|r@1|o|r| |m|e|s@1|a|g|e| |w|i|l@1| |b|e| |g|i|v|e|n| @3
11+
|a|n|d| |t|h|e| |f|o|l@1|o|w|i|n|g| |a|r|g|u|m|e|n|t|s| |w|i|l@1| |b|e| |i|g|n|o
12+
|r|e|d|.| @35
13+
@40
14+
@40
15+
@16|*|:|s|e|t|-|v|e|r|b|o|s|e|*| @9
16+
>W+8&&|h|e|n| |'|v|e|r|b|o|s|e|'| |i|s| |n|o|n|-|z|e|r|o|,| |d|i|s|p|l|a|y|i|n|g| |a
17+
|n| |o|p|t|i|o|n| |v|a|l|u|e| |w|i|l@1| |a|l|s|o| |t|e|l@1| |w|h|e|r|e| |i|t| @1
18+
|w+0&&|a|s| |l|a|s|t| |s|e|t|.| @1|E|x|a|m|p|l|e|:| |>| @14
19+
@8|:|v|e|r|b|o|s|e| |s|e|t| |s|h|i|f|t|w|i|d|t|h| |c|i|n|d|e|n|t|?
20+
|<| |2@1|L|,| |9|4|2|B| @10|1|2|,|1| @9|2|0|%|
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
| +0&#ffffff0@39
2+
|T|h|e| |{|o|p|t|i|o|n|}| |a|r|g|u|m|e|n|t|s| |t|o| |"|:|s|e|t|"| |m|a|y| |b|e|
3+
|r|e|p|e|a|t|e|d|.| @1|F|o|r| |e|x|a|m|p|l|e|:| |>| @14
4+
| +8&&@7>:|s|e|t| |a|i| |n|o|s|i| |s|w|=|3| |t|s|=|3| @9
5+
|I+0&&|f| |y|o|u| |m|a|k|e| |a|n| |e|r@1|o|r| |i|n| |o|n|e| |o|f| |t|h|e| |a|r|g|u|m
6+
|e|n|t|s|,| |a|n| |e|r@1|o|r| |m|e|s@1|a|g|e| |w|i|l@1| |b|e| |g|i|v|e|n| @3
7+
|a|n|d| |t|h|e| |f|o|l@1|o|w|i|n|g| |a|r|g|u|m|e|n|t|s| |w|i|l@1| |b|e| |i|g|n|o
8+
|r|e|d|.| @35
9+
@40
10+
@40
11+
@16|*|:|s|e|t|-|v|e|r|b|o|s|e|*| @9
12+
|W|h|e|n| |'|v|e|r|b|o|s|e|'| |i|s| |n|o|n|-|z|e|r|o|,| |d|i|s|p|l|a|y|i|n|g| |a
13+
|n| |o|p|t|i|o|n| |v|a|l|u|e| |w|i|l@1| |a|l|s|o| |t|e|l@1| |w|h|e|r|e| |i|t| @1
14+
|w|a|s| |l|a|s|t| |s|e|t|.| @1|E|x|a|m|p|l|e|:| |>| @14
15+
@8|:|v|e|r|b|o|s|e| |s|e|t| |s|h|i|f|t|w|i|d|t|h| |c|i|n|d|e|n|t|?
16+
|<| @1|s|h|i|f|t|w|i|d|t|h|=|4| |~| @22
17+
@10|L|a|s|t| |s|e|t| |f|r|o|m| |m|o|d|e|l|i|n|e| |l|i|n|e| |1|
18+
|~| @38
19+
@2|c|i|n|d|e|n|t| |~| @28
20+
@22|7|,|2|-|9| @8|4@1|%|

src/testdir/test_cursorline.vim

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ endfunc
110110
func Test_cursorline_screenline()
111111
CheckScreendump
112112
CheckOption cursorlineopt
113+
113114
let filename='Xcursorline'
114115
let lines = []
115116

@@ -197,4 +198,52 @@ func Test_cursorline_screenline()
197198
call delete(filename)
198199
endfunc
199200

201+
func Test_cursorline_redraw()
202+
CheckScreendump
203+
CheckOption cursorlineopt
204+
205+
let textlines =<< END
206+
When the option is a list of flags, {value} must be
207+
exactly as they appear in the option. Remove flags
208+
one by one to avoid problems.
209+
Also see |:set-args| above.
210+
211+
The {option} arguments to ":set" may be repeated. For example: >
212+
:set ai nosi sw=3 ts=3
213+
If you make an error in one of the arguments, an error message will be given
214+
and the following arguments will be ignored.
215+
216+
*:set-verbose*
217+
When 'verbose' is non-zero, displaying an option value will also tell where it
218+
was last set. Example: >
219+
:verbose set shiftwidth cindent?
220+
< shiftwidth=4 ~
221+
Last set from modeline line 1 ~
222+
cindent ~
223+
Last set from /usr/local/share/vim/vim60/ftplugin/c.vim line 30 ~
224+
This is only done when specific option values are requested, not for ":verbose
225+
set all" or ":verbose set" without an argument.
226+
When the option was set by hand there is no "Last set" message.
227+
When the option was set while executing a function, user command or
228+
END
229+
call writefile(textlines, 'Xtextfile')
230+
231+
let script =<< trim END
232+
set cursorline scrolloff=2
233+
normal 12G
234+
END
235+
call writefile(script, 'Xscript')
236+
237+
let buf = RunVimInTerminal('-S Xscript Xtextfile', #{rows: 20, cols: 40})
238+
call VerifyScreenDump(buf, 'Test_cursorline_redraw_1', {})
239+
call term_sendkeys(buf, "zt")
240+
call TermWait(buf)
241+
call term_sendkeys(buf, "\<C-U>")
242+
call VerifyScreenDump(buf, 'Test_cursorline_redraw_2', {})
243+
244+
call StopVimInTerminal(buf)
245+
call delete('Xscript')
246+
call delete('Xtextfile')
247+
endfunc
248+
200249
" vim: shiftwidth=2 sts=2 expandtab

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,8 @@ static char *(features[]) =
755755

756756
static int included_patches[] =
757757
{ /* Add new patch number below this line */
758+
/**/
759+
3204,
758760
/**/
759761
3203,
760762
/**/

0 commit comments

Comments
 (0)