Skip to content

Commit ecb87dd

Browse files
zeertzjqbrammool
authored andcommitted
patch 9.0.1602: stray character visible if marker on top of double-wide char
Problem: Stray character is visible if 'smoothscroll' marker is displayed on top of a double-wide character. Solution: When overwriting a double-width character with the 'smoothscroll' marker clear the second half. (closes #12469)
1 parent 664fd12 commit ecb87dd

5 files changed

Lines changed: 77 additions & 0 deletions

File tree

src/drawline.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,7 @@ wlv_screen_line(win_T *wp, winlinevars_T *wlv, int negative_width)
823823
&& !(wp->w_p_list && wp->w_lcs_chars.prec != 0))
824824
{
825825
int off = (int)(current_ScreenLine - ScreenLines);
826+
int max_off = off + screen_Columns;
826827
int skip = 0;
827828

828829
if (wp->w_p_nu && wp->w_p_rnu)
@@ -836,6 +837,10 @@ wlv_screen_line(win_T *wp, winlinevars_T *wlv, int negative_width)
836837

837838
for (int i = 0; i < 3 && i + skip < wp->w_width; ++i)
838839
{
840+
if ((*mb_off2cells)(off, max_off) > 1)
841+
// When the first half of a double-width character is
842+
// overwritten, change the second half to a space.
843+
ScreenLines[off + 1] = ' ';
839844
ScreenLines[off] = '<';
840845
if (enc_utf8)
841846
ScreenLinesUC[off] = 0;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
>a+0&#ffffff0@39
2+
|口*&@9| +&@19
3+
|~+0#4040ff13&| @38
4+
|~| @38
5+
|~| @38
6+
| +0#0000000&@21|1|,|1| @10|A|l@1|
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
|<+0#4040ff13#ffffff0@2| +0#0000000&|口*&@6>口| +&@19
2+
|~+0#4040ff13&| @38
3+
|~| @38
4+
|~| @38
5+
|~| @38
6+
| +0#0000000&@21|1|,|6|8|-|5|9| @6|A|l@1|

src/testdir/test_scroll_opt.vim

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,64 @@ func Test_smoothscroll_long_line_showbreak()
399399
call StopVimInTerminal(buf)
400400
endfunc
401401

402+
" Check that 'smoothscroll' marker is drawn over double-width char correctly.
403+
" Run with multiple encodings.
404+
func Test_smoothscroll_marker_over_double_width()
405+
" Run this in a separate Vim instance to avoid messing up.
406+
let after =<< trim [CODE]
407+
scriptencoding utf-8
408+
call setline(1, 'a'->repeat(&columns) .. ''->repeat(10))
409+
setlocal smoothscroll
410+
redraw
411+
exe "norm \<C-E>"
412+
redraw
413+
" Check the chars one by one. Don't check the whole line concatenated.
414+
call assert_equal('<', screenstring(1, 1))
415+
call assert_equal('<', screenstring(1, 2))
416+
call assert_equal('<', screenstring(1, 3))
417+
call assert_equal(' ', screenstring(1, 4))
418+
call assert_equal('', screenstring(1, 5))
419+
call assert_equal('', screenstring(1, 7))
420+
call assert_equal('', screenstring(1, 9))
421+
call assert_equal('', screenstring(1, 11))
422+
call assert_equal('', screenstring(1, 13))
423+
call assert_equal('', screenstring(1, 15))
424+
call writefile(v:errors, 'Xresult')
425+
qall!
426+
[CODE]
427+
428+
let encodings = ['utf-8', 'cp932', 'cp936', 'cp949', 'cp950']
429+
if !has('win32')
430+
let encodings += ['euc-jp']
431+
endif
432+
for enc in encodings
433+
let msg = 'enc=' .. enc
434+
if RunVim([], after, $'--clean --cmd "set encoding={enc}"')
435+
call assert_equal([], readfile('Xresult'), msg)
436+
endif
437+
call delete('Xresult')
438+
endfor
439+
endfunc
440+
441+
" Same as the test above, but check the text actually shown on screen.
442+
" Only run with UTF-8 encoding.
443+
func Test_smoothscroll_marker_over_double_width_dump()
444+
CheckScreendump
445+
446+
let lines =<< trim END
447+
call setline(1, 'a'->repeat(&columns) .. ''->repeat(10))
448+
setlocal smoothscroll
449+
END
450+
call writefile(lines, 'XSmoothMarkerOverDoubleWidth', 'D')
451+
let buf = RunVimInTerminal('-S XSmoothMarkerOverDoubleWidth', #{rows: 6, cols: 40})
452+
call VerifyScreenDump(buf, 'Test_smooth_marker_over_double_width_1', {})
453+
454+
call term_sendkeys(buf, "\<C-E>")
455+
call VerifyScreenDump(buf, 'Test_smooth_marker_over_double_width_2', {})
456+
457+
call StopVimInTerminal(buf)
458+
endfunc
459+
402460
func s:check_col_calc(win_col, win_line, buf_col)
403461
call assert_equal(a:win_col, wincol())
404462
call assert_equal(a:win_line, winline())

src/version.c

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

696696
static int included_patches[] =
697697
{ /* Add new patch number below this line */
698+
/**/
699+
1602,
698700
/**/
699701
1601,
700702
/**/

0 commit comments

Comments
 (0)