commit a98970219ddc90b6f599203f6bb24da79fc6bbeb
parent e38ae3b74ff513d991f8212dfbba75fe8c66aad3
Author: zeertzjq <zeertzjq@outlook.com>
Date: Thu, 24 Nov 2022 19:05:53 +0800
vim-patch:8.2.4062: match highlighting of tab too short
Problem: Match highlighting of tab too short.
Solution: Do not stop match highlighting if on a Tab. (Christian Brabandt,
closes vim/vim#9507, closes vim/vim#9500)
https://github.com/vim/vim/commit/0bbca540f7377889e2154aa5731f6eeffcb5c0cc
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat:
3 files changed, 47 insertions(+), 2 deletions(-)
diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c
@@ -1844,9 +1844,10 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
n_extra = 0;
}
}
- if (on_last_col) {
+ if (on_last_col && c != TAB) {
// Do not continue search/match highlighting over the
- // line break.
+ // line break, but for TABs the highlighting should
+ // include the complete width of the character
search_attr = 0;
}
diff --git a/src/nvim/testdir/test_match.vim b/src/nvim/testdir/test_match.vim
@@ -421,4 +421,22 @@ func Test_matchdelete_redraw()
bw!
endfunc
+func Test_match_tab_with_linebreak()
+ CheckRunVimInTerminal
+
+ let lines =<< trim END
+ set linebreak
+ call setline(1, "\tix")
+ call matchadd('ErrorMsg', '\t')
+ END
+ call writefile(lines, 'XscriptMatchTabLinebreak')
+ let buf = RunVimInTerminal('-S XscriptMatchTabLinebreak', #{rows: 10})
+ call TermWait(buf)
+ call VerifyScreenDump(buf, 'Test_match_tab_linebreak', {})
+
+ call StopVimInTerminal(buf)
+ call delete('XscriptMatchTabLinebreak')
+endfunc
+
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/functional/legacy/match_spec.lua b/test/functional/legacy/match_spec.lua
@@ -97,4 +97,30 @@ describe('match highlighting', function()
:s/0^ |
]])
end)
+
+ it('on a Tab vim-patch:8.2.4062', function()
+ local screen = Screen.new(75, 10)
+ screen:set_default_attr_ids({
+ [0] = {bold = true, foreground = Screen.colors.Blue}, -- NonText
+ [1] = {background = Screen.colors.Red, foreground = Screen.colors.White}, -- ErrorMsg
+ })
+ screen:attach()
+ exec([[
+ set linebreak
+ call setline(1, "\tix")
+ call matchadd('ErrorMsg', '\t')
+ ]])
+ screen:expect([[
+ {1: ^ }ix |
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ |
+ ]])
+ end)
end)