Skip to content

Commit

Permalink
fix(drawline): fix missing Visual hl on double-width fold char (neovi…
Browse files Browse the repository at this point in the history
  • Loading branch information
zeertzjq authored Jul 11, 2023
1 parent 19fb573 commit 0669420
Show file tree
Hide file tree
Showing 2 changed files with 201 additions and 19 deletions.
8 changes: 5 additions & 3 deletions src/nvim/drawline.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
212 changes: 196 additions & 16 deletions test/functional/ui/fold_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -2533,23 +2533,203 @@ 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
{11:-- VISUAL BLOCK --} |
]])
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 --} |
Expand Down

0 comments on commit 0669420

Please sign in to comment.