fix(folds): show Folded highlight in Visual selection (#23741)

Note: CursorLine highlight is now combined with Folded.
This commit is contained in:
zeertzjq 2023-05-24 21:25:39 +08:00 committed by GitHub
parent c855eee919
commit 678548a2b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 71 additions and 16 deletions

View File

@ -1807,8 +1807,8 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
}
int extmark_attr = 0;
if (wlv.draw_state == WL_LINE
&& (area_highlighting || has_spell || (extra_check && !has_fold))) {
if (wlv.draw_state == WL_LINE && !has_fold
&& (area_highlighting || 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

View File

@ -42,7 +42,9 @@ describe("folded lines", function()
[9] = {bold = true, foreground = Screen.colors.Brown},
[10] = {background = Screen.colors.LightGrey, underline = true},
[11] = {bold=true},
[12] = {background = Screen.colors.Grey90},
[12] = {background = Screen.colors.Grey90, underline = true},
[13] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey, underline = true},
[14] = {background = Screen.colors.LightGray},
})
end)
@ -86,9 +88,10 @@ describe("folded lines", function()
end
end)
it("highlights with CursorLineFold when 'cursorline' is set", function()
it("foldcolumn highlighted with CursorLineFold when 'cursorline' is set", function()
command("set number cursorline foldcolumn=2")
command("hi link CursorLineFold Search")
command("hi! CursorLine gui=underline guibg=Grey90")
insert(content1)
feed("ggzf3jj")
if multigrid then
@ -138,7 +141,7 @@ describe("folded lines", function()
[2:---------------------------------------------]|
[3:---------------------------------------------]|
## grid 2
{6:+ }{9: 1 }{12:^+-- 4 lines: This is a················}|
{6:+ }{9: 1 }{13:^+-- 4 lines: This is a················}|
{7: }{8: 5 }in his cave. |
{7: }{8: 6 } |
{1:~ }|
@ -150,7 +153,7 @@ describe("folded lines", function()
]])
else
screen:expect([[
{6:+ }{9: 1 }{12:^+-- 4 lines: This is a················}|
{6:+ }{9: 1 }{13:^+-- 4 lines: This is a················}|
{7: }{8: 5 }in his cave. |
{7: }{8: 6 } |
{1:~ }|
@ -179,7 +182,7 @@ describe("folded lines", function()
[2:---------------------------------------------]|
[3:---------------------------------------------]|
## grid 2
{7:+ }{8: 1 }{12:^+-- 4 lines: This is a················}|
{7:+ }{8: 1 }{13:^+-- 4 lines: This is a················}|
{7: }{8: 5 }in his cave. |
{7: }{8: 6 } |
{1:~ }|
@ -191,7 +194,7 @@ describe("folded lines", function()
]])
else
screen:expect([[
{7:+ }{8: 1 }{12:^+-- 4 lines: This is a················}|
{7:+ }{8: 1 }{13:^+-- 4 lines: This is a················}|
{7: }{8: 5 }in his cave. |
{7: }{8: 6 } |
{1:~ }|
@ -2013,6 +2016,56 @@ describe("folded lines", function()
]])
end
end)
it('Folded highlight does not disappear in Visual selection #19691', function()
insert([[
" foo
" {{{1
set nocp
" }}}1
" bar
" {{{1
set foldmethod=marker
" }}}1
" baz]])
feed('gg')
command('source')
feed('<C-V>G3l')
if multigrid then
screen:expect([[
## grid 1
[2:---------------------------------------------]|
[2:---------------------------------------------]|
[2:---------------------------------------------]|
[2:---------------------------------------------]|
[2:---------------------------------------------]|
[2:---------------------------------------------]|
[2:---------------------------------------------]|
[3:---------------------------------------------]|
## grid 2
{14:" fo}o |
{5:+-- 3 lines: "······························}|
{14:" ba}r |
{5:+-- 3 lines: "······························}|
{14:" b}^az |
{1:~ }|
{1:~ }|
## grid 3
{11:-- VISUAL BLOCK --} |
]])
else
screen:expect([[
{14:" fo}o |
{5:+-- 3 lines: "······························}|
{14:" ba}r |
{5:+-- 3 lines: "······························}|
{14:" b}^az |
{1:~ }|
{1:~ }|
{11:-- VISUAL BLOCK --} |
]])
end
end)
end
describe("with ext_multigrid", function()

View File

@ -196,8 +196,10 @@ describe('statuscolumn', function()
[2] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGrey},
[3] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey},
[4] = {bold = true, foreground = Screen.colors.Brown},
[5] = {background = Screen.colors.Grey90},
[5] = {background = Screen.colors.Grey90, underline = true},
[6] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey, underline = true},
})
command('hi! CursorLine gui=underline guibg=Grey90')
screen:expect([[
{1: 4 }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{1: }a |
@ -214,7 +216,7 @@ describe('statuscolumn', function()
{1:10 }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{0:@@@}|
|
]])
command("set stc=%C%s%=%l│\\ ")
command([[set stc=%C%s%=%l│\ ]])
screen:expect_unchanged()
command('set signcolumn=auto:2 foldcolumn=auto')
command('sign define piet1 text=>> texthl=LineNr')
@ -268,7 +270,7 @@ describe('statuscolumn', function()
{2: }{1: }{2: }{1: }aaaaaa |
{2: }{1: 7}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{2: }{1: }{2: }{1: }aaaaaa |
{2:+}{4: 8}{2: }{4: }{5:^+-- 1 line: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}|
{2:+}{4: 8}{2: }{4: }{6:^+-- 1 line: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}|
{2: }{1: 9}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{2: }{1: }{2: }{1: }aaaaaa |
{2: }{1:10}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
@ -286,7 +288,7 @@ describe('statuscolumn', function()
{2: }{1: 6}{2: }{1: }aaaaaa |
{2: }{1: 7}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{2: }{1: 7}{2: }{1: }aaaaaa |
{2:+}{4: 8}{2: }{4: }{5:^+-- 1 line: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}|
{2:+}{4: 8}{2: }{4: }{6:^+-- 1 line: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}|
{2: }{1: 9}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{2: }{1: 9}{2: }{1: }aaaaaa |
{2: }{1:10}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
@ -304,7 +306,7 @@ describe('statuscolumn', function()
{2: }{1: 2}{2: }{1: }aaaaaa |
{2: }{1: 1}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{2: }{1: 1}{2: }{1: }aaaaaa |
{2:+}{4: 0}{2: }{4: }{5:^+-- 1 line: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}|
{2:+}{4: 0}{2: }{4: }{6:^+-- 1 line: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}|
{2: }{1: 1}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{2: }{1: 1}{2: }{1: }aaaaaa |
{2: }{1: 2}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
@ -321,7 +323,7 @@ describe('statuscolumn', function()
{2: }{1: }{2: }{1: }aaaaaa |
{2: }{1: 1}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{2: }{1: }{2: }{1: }aaaaaa |
{2:+}{4: 0}{2: }{4: }{5:^+-- 1 line: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}|
{2:+}{4: 0}{2: }{4: }{6:^+-- 1 line: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}|
{2: }{1: 1}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{2: }{1: }{2: }{1: }aaaaaa |
{2: }{1: 2}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
@ -346,7 +348,7 @@ describe('statuscolumn', function()
{2: }{1: }{2: }{1: }aaaaaaaaaaaaaaaaaaaa |
{2: }{1: 1}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{2: }{1: }{2: }{1: }aaaaaaaaaaaaaaaaaaaa |
{2:+}{4: 0}{2: }{4: }{5:^+-- 1 line: aaaaaaaaaaaaaaaaa}|
{2:+}{4: 0}{2: }{4: }{6:^+-- 1 line: aaaaaaaaaaaaaaaaa}|
{2: }{1: 1}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{2: }{1: }{2: }{1: }aaaaaaaaaaaaaaaaaaaa |
{2: }{1: 2}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
@ -372,7 +374,7 @@ describe('statuscolumn', function()
{1:wrapped 1 6}aaaaaaaa |
{1:buffer 0 7}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{1:wrapped 1 7}aaaaaaaa |
{4:buffer 0 8}{5:^+-- 1 line: aaaaaaaaaaaaaaaaaaaaaaaaaaaaa}|
{4:buffer 0 8}{6:^+-- 1 line: aaaaaaaaaaaaaaaaaaaaaaaaaaaaa}|
{1:buffer 0 9}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{1:wrapped 1 9}aaaaaaaa |
|