Patch 9.0.1602
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)
Files: src/drawline.c, src/testdir/test_scroll_opt.vim,
src/testdir/dumps/Test_smooth_marker_over_double_width_1.dump,
src/testdir/dumps/Test_smooth_marker_over_double_width_2.dump
*** ../vim-9.0.1601/src/drawline.c 2023-05-31 18:57:10.513953154 +0100
--- src/drawline.c 2023-06-03 19:43:59.414137721 +0100
***************
*** 823,828 ****
--- 823,829 ----
&& !(wp->w_p_list && wp->w_lcs_chars.prec != 0))
{
int off = (int)(current_ScreenLine - ScreenLines);
+ int max_off = off + screen_Columns;
int skip = 0;
if (wp->w_p_nu && wp->w_p_rnu)
***************
*** 836,841 ****
--- 837,846 ----
for (int i = 0; i < 3 && i + skip < wp->w_width; ++i)
{
+ if ((*mb_off2cells)(off, max_off) > 1)
+ // When the first half of a double-width character is
+ // overwritten, change the second half to a space.
+ ScreenLines[off + 1] = ' ';
ScreenLines[off] = '<';
if (enc_utf8)
ScreenLinesUC[off] = 0;
*** ../vim-9.0.1601/src/testdir/test_scroll_opt.vim 2023-05-19
14:04:23.133885852 +0100
--- src/testdir/test_scroll_opt.vim 2023-06-03 19:19:17.631718177 +0100
***************
*** 399,404 ****
--- 399,462 ----
call StopVimInTerminal(buf)
endfunc
+ " Check that 'smoothscroll' marker is drawn over double-width char correctly.
+ " Run with multiple encodings.
+ func Test_smoothscroll_marker_over_double_width()
+ " Run this in a separate Vim instance to avoid messing up.
+ let after =<< trim [CODE]
+ scriptencoding utf-8
+ call setline(1, 'a'->repeat(&columns) .. '口'->repeat(10))
+ setlocal smoothscroll
+ redraw
+ exe "norm \<C-E>"
+ redraw
+ " Check the chars one by one. Don't check the whole line concatenated.
+ call assert_equal('<', screenstring(1, 1))
+ call assert_equal('<', screenstring(1, 2))
+ call assert_equal('<', screenstring(1, 3))
+ call assert_equal(' ', screenstring(1, 4))
+ call assert_equal('口', screenstring(1, 5))
+ call assert_equal('口', screenstring(1, 7))
+ call assert_equal('口', screenstring(1, 9))
+ call assert_equal('口', screenstring(1, 11))
+ call assert_equal('口', screenstring(1, 13))
+ call assert_equal('口', screenstring(1, 15))
+ call writefile(v:errors, 'Xresult')
+ qall!
+ [CODE]
+
+ let encodings = ['utf-8', 'cp932', 'cp936', 'cp949', 'cp950']
+ if !has('win32')
+ let encodings += ['euc-jp']
+ endif
+ for enc in encodings
+ let msg = 'enc=' .. enc
+ if RunVim([], after, $'--clean --cmd "set encoding={enc}"')
+ call assert_equal([], readfile('Xresult'), msg)
+ endif
+ call delete('Xresult')
+ endfor
+ endfunc
+
+ " Same as the test above, but check the text actually shown on screen.
+ " Only run with UTF-8 encoding.
+ func Test_smoothscroll_marker_over_double_width_dump()
+ CheckScreendump
+
+ let lines =<< trim END
+ call setline(1, 'a'->repeat(&columns) .. '口'->repeat(10))
+ setlocal smoothscroll
+ END
+ call writefile(lines, 'XSmoothMarkerOverDoubleWidth', 'D')
+ let buf = RunVimInTerminal('-S XSmoothMarkerOverDoubleWidth', #{rows: 6,
cols: 40})
+ call VerifyScreenDump(buf, 'Test_smooth_marker_over_double_width_1', {})
+
+ call term_sendkeys(buf, "\<C-E>")
+ call VerifyScreenDump(buf, 'Test_smooth_marker_over_double_width_2', {})
+
+ call StopVimInTerminal(buf)
+ endfunc
+
func s:check_col_calc(win_col, win_line, buf_col)
call assert_equal(a:win_col, wincol())
call assert_equal(a:win_line, winline())
***
../vim-9.0.1601/src/testdir/dumps/Test_smooth_marker_over_double_width_1.dump
2023-06-03 19:42:53.466626287 +0100
--- src/testdir/dumps/Test_smooth_marker_over_double_width_1.dump
2023-06-03 19:19:17.631718177 +0100
***************
*** 0 ****
--- 1,6 ----
+ >a+0&#ffffff0@39
+ |口*&@9| +&@19
+ |~+0#4040ff13&| @38
+ |~| @38
+ |~| @38
+ | +0#0000000&@21|1|,|1| @10|A|l@1|
***
../vim-9.0.1601/src/testdir/dumps/Test_smooth_marker_over_double_width_2.dump
2023-06-03 19:42:53.474626225 +0100
--- src/testdir/dumps/Test_smooth_marker_over_double_width_2.dump
2023-06-03 19:19:17.631718177 +0100
***************
*** 0 ****
--- 1,6 ----
+ |<+0#4040ff13#ffffff0@2| +0#0000000&|口*&@6>口| +&@19
+ |~+0#4040ff13&| @38
+ |~| @38
+ |~| @38
+ |~| @38
+ | +0#0000000&@21|1|,|6|8|-|5|9| @6|A|l@1|
*** ../vim-9.0.1601/src/version.c 2023-06-03 17:56:26.632203045 +0100
--- src/version.c 2023-06-03 19:42:08.210990902 +0100
***************
*** 697,698 ****
--- 697,700 ----
{ /* Add new patch number below this line */
+ /**/
+ 1602,
/**/
--
hundred-and-one symptoms of being an internet addict:
108. While reading a magazine, you look for the Zoom icon for a better
look at a photograph.
/// Bram Moolenaar -- [email protected] -- 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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/20230603184546.52D531C0595%40moolenaar.net.