aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-07-11 13:16:31 +0800
committerGitHub <noreply@github.com>2023-07-11 13:16:31 +0800
commit06694203e51efbabc0b49e26704dff089011fd21 (patch)
treee332f6cf47358f04478d692927cacb06422eded1
parent19fb573ad992b6f658b58159314eeea0c2f30953 (diff)
downloadrneovim-06694203e51efbabc0b49e26704dff089011fd21.tar.gz
rneovim-06694203e51efbabc0b49e26704dff089011fd21.tar.bz2
rneovim-06694203e51efbabc0b49e26704dff089011fd21.zip
fix(drawline): fix missing Visual hl on double-width fold char (#24308)
-rw-r--r--src/nvim/drawline.c8
-rw-r--r--test/functional/ui/fold_spec.lua212
2 files changed, 201 insertions, 19 deletions
diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c
index 7bd0f67014..6bf9dc845d 100644
--- a/src/nvim/drawline.c
+++ b/src/nvim/drawline.c
@@ -1805,9 +1805,11 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl
&& (area_highlighting || spv->spv_has_spell || extra_check)) {
// handle Visual or match highlighting in this line
if (wlv.vcol == wlv.fromcol
- || (wlv.vcol + 1 == wlv.fromcol && wlv.n_extra == 0
- && utf_ptr2cells(ptr) > 1)
- || ((int)vcol_prev == fromcol_prev
+ || (wlv.vcol + 1 == wlv.fromcol
+ && ((wlv.n_extra == 0 && utf_ptr2cells(ptr) > 1)
+ || (wlv.n_extra > 0 && wlv.p_extra != NULL
+ && utf_ptr2cells(wlv.p_extra) > 1)))
+ || (vcol_prev == fromcol_prev
&& vcol_prev < wlv.vcol // not at margin
&& wlv.vcol < wlv.tocol)) {
area_attr = vi_attr; // start highlighting
diff --git a/test/functional/ui/fold_spec.lua b/test/functional/ui/fold_spec.lua
index d3119ccc42..f00fba331e 100644
--- a/test/functional/ui/fold_spec.lua
+++ b/test/functional/ui/fold_spec.lua
@@ -2509,18 +2509,18 @@ describe("folded lines", function()
it('Folded and Visual highlights are combined #19691', function()
command('hi! Visual guibg=Red')
insert([[
- " foo
- " {{{1
+ " foofoofoofoofoofoo
+ " 口 {{{1
set nocp
" }}}1
- " bar
- " {{{1
+ " barbarbarbarbarbar
+ " 口 {{{1
set foldmethod=marker
" }}}1
- " baz]])
+ " bazbazbazbazbazbaz]])
feed('gg')
command('source')
- feed('<C-V>G3l')
+ feed('<C-V>G15l')
if multigrid then
screen:expect([[
## grid 1
@@ -2533,11 +2533,11 @@ describe("folded lines", function()
[2:---------------------------------------------]|
[3:---------------------------------------------]|
## grid 2
- {14:" fo}o |
- {15:+-- }{5: 3 lines: "······························}|
- {14:" ba}r |
- {15:+-- }{5: 3 lines: "······························}|
- {14:" b}^az |
+ {14:" foofoofoofoofo}ofoo |
+ {15:+-- 3 lines: " }{5:口···························}|
+ {14:" barbarbarbarba}rbar |
+ {15:+-- 3 lines: " }{5:口···························}|
+ {14:" bazbazbazbazb}^azbaz |
{1:~ }|
{1:~ }|
## grid 3
@@ -2545,11 +2545,191 @@ describe("folded lines", function()
]])
else
screen:expect([[
- {14:" fo}o |
- {15:+-- }{5: 3 lines: "······························}|
- {14:" ba}r |
- {15:+-- }{5: 3 lines: "······························}|
- {14:" b}^az |
+ {14:" foofoofoofoofo}ofoo |
+ {15:+-- 3 lines: " }{5:口···························}|
+ {14:" barbarbarbarba}rbar |
+ {15:+-- 3 lines: " }{5:口···························}|
+ {14:" bazbazbazbazb}^azbaz |
+ {1:~ }|
+ {1:~ }|
+ {11:-- VISUAL BLOCK --} |
+ ]])
+ end
+
+ feed('l')
+ if multigrid then
+ screen:expect([[
+ ## grid 1
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [3:---------------------------------------------]|
+ ## grid 2
+ {14:" foofoofoofoofoo}foo |
+ {15:+-- 3 lines: " 口}{5:···························}|
+ {14:" barbarbarbarbar}bar |
+ {15:+-- 3 lines: " 口}{5:···························}|
+ {14:" bazbazbazbazba}^zbaz |
+ {1:~ }|
+ {1:~ }|
+ ## grid 3
+ {11:-- VISUAL BLOCK --} |
+ ]])
+ else
+ screen:expect([[
+ {14:" foofoofoofoofoo}foo |
+ {15:+-- 3 lines: " 口}{5:···························}|
+ {14:" barbarbarbarbar}bar |
+ {15:+-- 3 lines: " 口}{5:···························}|
+ {14:" bazbazbazbazba}^zbaz |
+ {1:~ }|
+ {1:~ }|
+ {11:-- VISUAL BLOCK --} |
+ ]])
+ end
+
+ feed('l')
+ if multigrid then
+ screen:expect([[
+ ## grid 1
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [3:---------------------------------------------]|
+ ## grid 2
+ {14:" foofoofoofoofoof}oo |
+ {15:+-- 3 lines: " 口}{5:···························}|
+ {14:" barbarbarbarbarb}ar |
+ {15:+-- 3 lines: " 口}{5:···························}|
+ {14:" bazbazbazbazbaz}^baz |
+ {1:~ }|
+ {1:~ }|
+ ## grid 3
+ {11:-- VISUAL BLOCK --} |
+ ]])
+ else
+ screen:expect([[
+ {14:" foofoofoofoofoof}oo |
+ {15:+-- 3 lines: " 口}{5:···························}|
+ {14:" barbarbarbarbarb}ar |
+ {15:+-- 3 lines: " 口}{5:···························}|
+ {14:" bazbazbazbazbaz}^baz |
+ {1:~ }|
+ {1:~ }|
+ {11:-- VISUAL BLOCK --} |
+ ]])
+ end
+
+ feed('2l')
+ if multigrid then
+ screen:expect([[
+ ## grid 1
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [3:---------------------------------------------]|
+ ## grid 2
+ {14:" foofoofoofoofoofoo} |
+ {15:+-- 3 lines: " 口··}{5:·························}|
+ {14:" barbarbarbarbarbar} |
+ {15:+-- 3 lines: " 口··}{5:·························}|
+ {14:" bazbazbazbazbazba}^z |
+ {1:~ }|
+ {1:~ }|
+ ## grid 3
+ {11:-- VISUAL BLOCK --} |
+ ]])
+ else
+ screen:expect([[
+ {14:" foofoofoofoofoofoo} |
+ {15:+-- 3 lines: " 口··}{5:·························}|
+ {14:" barbarbarbarbarbar} |
+ {15:+-- 3 lines: " 口··}{5:·························}|
+ {14:" bazbazbazbazbazba}^z |
+ {1:~ }|
+ {1:~ }|
+ {11:-- VISUAL BLOCK --} |
+ ]])
+ end
+
+ feed('O16l')
+ if multigrid then
+ screen:expect([[
+ ## grid 1
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [3:---------------------------------------------]|
+ ## grid 2
+ " foofoofoofoofo{14:ofoo} |
+ {5:+-- 3 lines: " }{15:口··}{5:·························}|
+ " barbarbarbarba{14:rbar} |
+ {5:+-- 3 lines: " }{15:口··}{5:·························}|
+ " bazbazbazbazba^z{14:baz} |
+ {1:~ }|
+ {1:~ }|
+ ## grid 3
+ {11:-- VISUAL BLOCK --} |
+ ]])
+ else
+ screen:expect([[
+ " foofoofoofoofo{14:ofoo} |
+ {5:+-- 3 lines: " }{15:口··}{5:·························}|
+ " barbarbarbarba{14:rbar} |
+ {5:+-- 3 lines: " }{15:口··}{5:·························}|
+ " bazbazbazbazba^z{14:baz} |
+ {1:~ }|
+ {1:~ }|
+ {11:-- VISUAL BLOCK --} |
+ ]])
+ end
+
+ feed('l')
+ if multigrid then
+ screen:expect([[
+ ## grid 1
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [3:---------------------------------------------]|
+ ## grid 2
+ " foofoofoofoofoo{14:foo} |
+ {5:+-- 3 lines: " }{15:口··}{5:·························}|
+ " barbarbarbarbar{14:bar} |
+ {5:+-- 3 lines: " }{15:口··}{5:·························}|
+ " bazbazbazbazbaz^b{14:az} |
+ {1:~ }|
+ {1:~ }|
+ ## grid 3
+ {11:-- VISUAL BLOCK --} |
+ ]])
+ else
+ screen:expect([[
+ " foofoofoofoofoo{14:foo} |
+ {5:+-- 3 lines: " }{15:口··}{5:·························}|
+ " barbarbarbarbar{14:bar} |
+ {5:+-- 3 lines: " }{15:口··}{5:·························}|
+ " bazbazbazbazbaz^b{14:az} |
{1:~ }|
{1:~ }|
{11:-- VISUAL BLOCK --} |