fix(highlight): no match highlight during :substitute prompt #33262

Problem:  Redrawing during a substitute confirm prompt causes the match
          highlight to disappear.
Solution: Unset `highlight_match` after the prompt has returned.
          Use global highlight definitions in searchhl_spec.lua.
(cherry picked from commit 3af43cffa0)
This commit is contained in:
luukvbaal
2025-04-02 14:14:11 +02:00
committed by github-actions[bot]
parent 5fc6bd6454
commit 279a0e78c9
2 changed files with 158 additions and 181 deletions

View File

@@ -3788,7 +3788,6 @@ static int do_sub(exarg_T *eap, const proftime_T timeout, const int cmdpreview_n
redraw_later(curwin, UPD_SOME_VALID); redraw_later(curwin, UPD_SOME_VALID);
show_cursor_info_later(true); show_cursor_info_later(true);
update_screen(); update_screen();
highlight_match = false;
redraw_later(curwin, UPD_SOME_VALID); redraw_later(curwin, UPD_SOME_VALID);
curwin->w_p_fen = save_p_fen; curwin->w_p_fen = save_p_fen;
@@ -3797,6 +3796,7 @@ static int do_sub(exarg_T *eap, const proftime_T timeout, const int cmdpreview_n
snprintf(IObuff, IOSIZE, p, sub); snprintf(IObuff, IOSIZE, p, sub);
p = xstrdup(IObuff); p = xstrdup(IObuff);
typed = prompt_for_input(p, HLF_R, true, NULL); typed = prompt_for_input(p, HLF_R, true, NULL);
highlight_match = false;
xfree(p); xfree(p);
msg_didout = false; // don't scroll up msg_didout = false; // don't scroll up

View File

@@ -16,13 +16,12 @@ describe('search highlighting', function()
before_each(function() before_each(function()
clear() clear()
screen = Screen.new(40, 7) screen = Screen.new(40, 7)
screen:set_default_attr_ids({ screen:add_extra_attr_ids({
[1] = { bold = true, foreground = Screen.colors.Blue }, [100] = { foreground = Screen.colors.Gray100, background = Screen.colors.Grey0 },
[2] = { background = Screen.colors.Yellow }, -- Search [101] = { foreground = Screen.colors.White, background = Screen.colors.DarkGreen },
[3] = { reverse = true }, [102] = { background = Screen.colors.WebGreen, bold = true },
[4] = { foreground = Screen.colors.Red }, -- WarningMsg [103] = { background = Screen.colors.Magenta1, italic = true },
[5] = { bold = true, reverse = true }, -- StatusLine [104] = { background = Screen.colors.Yellow1, bold = true },
[6] = { foreground = Screen.colors.Blue4, background = Screen.colors.LightGrey }, -- Folded
}) })
end) end)
@@ -44,7 +43,7 @@ describe('search highlighting', function()
feed('gg/text') feed('gg/text')
screen:expect { screen:expect {
grid = [[ grid = [[
{6:+-- 2 lines: some text·················}| {13:+-- 2 lines: some text·················}|
{1:~ }|*5 {1:~ }|*5
/text^ | /text^ |
]], ]],
@@ -73,35 +72,35 @@ describe('search highlighting', function()
-- 'hlsearch' is enabled by default. #2859 -- 'hlsearch' is enabled by default. #2859
feed('gg/text<cr>') feed('gg/text<cr>')
screen:expect([[ screen:expect([[
some {2:^text} | some {100:^text} |
more {2:text}stuff | more {100:text}stuff |
stupid{2:texttext}stuff | stupid{100:texttext}stuff |
a {2:text} word | a {100:text} word |
| |
{1:~ }| {101:~ }|
/text | /text |
]]) ]])
-- overlapping matches not allowed -- overlapping matches not allowed
feed('3nx') feed('3nx')
screen:expect([[ screen:expect([[
some {2:text} | some {100:text} |
more {2:text}stuff | more {100:text}stuff |
stupid{2:text}^extstuff | stupid{100:text}^extstuff |
a {2:text} word | a {100:text} word |
| |
{1:~ }| {101:~ }|
/text | /text |
]]) ]])
feed('ggn*') -- search for entire word feed('ggn*') -- search for entire word
screen:expect([[ screen:expect([[
some {2:text} | some {100:text} |
more textstuff | more textstuff |
stupidtextextstuff | stupidtextextstuff |
a {2:^text} word | a {100:^text} word |
| |
{1:~ }| {101:~ }|
/\<text\> | /\<text\> |
]]) ]])
@@ -112,38 +111,39 @@ describe('search highlighting', function()
stupidtextextstuff | stupidtextextstuff |
a ^text word | a ^text word |
| |
{1:~ }| {101:~ }|
:nohlsearch | :nohlsearch |
]]) ]])
end end
it("works when 'winhighlight' is not set", function() it("works when 'winhighlight' is not set", function()
screen:add_extra_attr_ids({
[100] = { background = Screen.colors.Yellow1 },
[101] = { foreground = Screen.colors.Blue1, bold = true },
})
test_search_hl() test_search_hl()
end) end)
it("works when 'winhighlight' doesn't change Search highlight", function() it("works when 'winhighlight' doesn't change Search highlight", function()
command('setlocal winhl=NonText:Underlined') command('setlocal winhl=NonText:Underlined')
local attrs = screen:get_default_attr_ids() screen:add_extra_attr_ids({
attrs[1] = { foreground = Screen.colors.SlateBlue, underline = true } [100] = { background = Screen.colors.Yellow },
screen:set_default_attr_ids(attrs) [101] = { foreground = Screen.colors.SlateBlue, underline = true },
})
test_search_hl() test_search_hl()
end) end)
it("works when 'winhighlight' changes Search highlight", function() it("works when 'winhighlight' changes Search highlight", function()
command('setlocal winhl=Search:Underlined') command('setlocal winhl=Search:Underlined')
local attrs = screen:get_default_attr_ids() screen:add_extra_attr_ids({
attrs[2] = { foreground = Screen.colors.SlateBlue, underline = true } [100] = { foreground = Screen.colors.SlateBlue, underline = true },
screen:set_default_attr_ids(attrs) [101] = { foreground = Screen.colors.Blue1, bold = true },
})
test_search_hl() test_search_hl()
end) end)
describe('CurSearch highlight', function() describe('CurSearch highlight', function()
before_each(function() before_each(function()
screen:set_default_attr_ids({
[1] = { background = Screen.colors.Yellow }, -- Search
[2] = { foreground = Screen.colors.White, background = Screen.colors.Black }, -- CurSearch
[3] = { foreground = Screen.colors.Red }, -- WarningMsg
})
command('highlight CurSearch guibg=Black guifg=White') command('highlight CurSearch guibg=Black guifg=White')
end) end)
@@ -157,43 +157,37 @@ describe('search highlighting', function()
humans think is impossible.]]) humans think is impossible.]])
feed('/bee<CR>') feed('/bee<CR>')
screen:expect { screen:expect([[
grid = [[ There is no way that a {100:^bee} should be |
There is no way that a {2:^bee} should be |
able to fly. Its wings are too small | able to fly. Its wings are too small |
to get its fat little body off the | to get its fat little body off the |
ground. The {1:bee}, of course, flies | ground. The {10:bee}, of course, flies |
anyway because {1:bee}s don't care what | anyway because {10:bee}s don't care what |
humans think is impossible. | humans think is impossible. |
{3:search hit BOTTOM, continuing at TOP} | {19:search hit BOTTOM, continuing at TOP} |
]], ]])
}
feed('nn') feed('nn')
screen:expect { screen:expect([[
grid = [[ There is no way that a {10:bee} should be |
There is no way that a {1:bee} should be |
able to fly. Its wings are too small | able to fly. Its wings are too small |
to get its fat little body off the | to get its fat little body off the |
ground. The {1:bee}, of course, flies | ground. The {10:bee}, of course, flies |
anyway because {2:^bee}s don't care what | anyway because {100:^bee}s don't care what |
humans think is impossible. | humans think is impossible. |
/bee | /bee |
]], ]])
}
feed('N') feed('N')
screen:expect { screen:expect([[
grid = [[ There is no way that a {10:bee} should be |
There is no way that a {1:bee} should be |
able to fly. Its wings are too small | able to fly. Its wings are too small |
to get its fat little body off the | to get its fat little body off the |
ground. The {2:^bee}, of course, flies | ground. The {100:^bee}, of course, flies |
anyway because {1:bee}s don't care what | anyway because {10:bee}s don't care what |
humans think is impossible. | humans think is impossible. |
?bee | ?bee |
]], ]])
}
end) end)
-- oldtest: Test_hlsearch_cursearch() -- oldtest: Test_hlsearch_cursearch()
@@ -202,40 +196,40 @@ describe('search highlighting', function()
feed('gg/foo<CR>') feed('gg/foo<CR>')
screen:expect([[ screen:expect([[
one | one |
{2:^foo} | {100:^foo} |
bar | bar |
baz | baz |
{1:foo} the {1:foo} and {1:foo} | {10:foo} the {10:foo} and {10:foo} |
bar | bar |
/foo | /foo |
]]) ]])
feed('n') feed('n')
screen:expect([[ screen:expect([[
one | one |
{1:foo} | {10:foo} |
bar | bar |
baz | baz |
{2:^foo} the {1:foo} and {1:foo} | {100:^foo} the {10:foo} and {10:foo} |
bar | bar |
/foo | /foo |
]]) ]])
feed('n') feed('n')
screen:expect([[ screen:expect([[
one | one |
{1:foo} | {10:foo} |
bar | bar |
baz | baz |
{1:foo} the {2:^foo} and {1:foo} | {10:foo} the {100:^foo} and {10:foo} |
bar | bar |
/foo | /foo |
]]) ]])
feed('n') feed('n')
screen:expect([[ screen:expect([[
one | one |
{1:foo} | {10:foo} |
bar | bar |
baz | baz |
{1:foo} the {1:foo} and {2:^foo} | {10:foo} the {10:foo} and {100:^foo} |
bar | bar |
/foo | /foo |
]]) ]])
@@ -243,42 +237,42 @@ describe('search highlighting', function()
feed('0?<CR>') feed('0?<CR>')
screen:expect([[ screen:expect([[
one | one |
{2:^foo} | {100:^foo} |
bar | bar |
baz | baz |
{1:foo} | {10:foo} |
bar | bar |
?foo | ?foo |
]]) ]])
feed('gg/foo\\nbar<CR>') feed('gg/foo\\nbar<CR>')
screen:expect([[ screen:expect([[
one | one |
{2:^foo } | {100:^foo } |
{2:bar} | {100:bar} |
baz | baz |
{1:foo } | {10:foo } |
{1:bar} | {10:bar} |
/foo\nbar | /foo\nbar |
]]) ]])
command([[call setline(1, ['---', 'abcdefg', 'hijkl', '---', 'abcdefg', 'hijkl'])]]) command([[call setline(1, ['---', 'abcdefg', 'hijkl', '---', 'abcdefg', 'hijkl'])]])
feed('gg/efg\\nhij<CR>') feed('gg/efg\\nhij<CR>')
screen:expect([[ screen:expect([[
--- | --- |
abcd{2:^efg } | abcd{100:^efg } |
{2:hij}kl | {100:hij}kl |
--- | --- |
abcd{1:efg } | abcd{10:efg } |
{1:hij}kl | {10:hij}kl |
/efg\nhij | /efg\nhij |
]]) ]])
feed('n') feed('n')
screen:expect([[ screen:expect([[
--- | --- |
abcd{1:efg } | abcd{10:efg } |
{1:hij}kl | {10:hij}kl |
--- | --- |
abcd{2:^efg } | abcd{100:^efg } |
{2:hij}kl | {100:hij}kl |
/efg\nhij | /efg\nhij |
]]) ]])
@@ -286,21 +280,21 @@ describe('search highlighting', function()
feed('G?^abcd<CR>Y') feed('G?^abcd<CR>Y')
screen:expect([[ screen:expect([[
--- | --- |
{1:abcd}efg | {10:abcd}efg |
hijkl | hijkl |
--- | --- |
{2:^abcd}efg | {100:^abcd}efg |
hijkl | hijkl |
?^abcd | ?^abcd |
]]) ]])
feed('kkP') feed('kkP')
screen:expect([[ screen:expect([[
--- | --- |
{1:abcd}efg | {10:abcd}efg |
{2:^abcd}efg | {100:^abcd}efg |
hijkl | hijkl |
--- | --- |
{1:abcd}efg | {10:abcd}efg |
?^abcd | ?^abcd |
]]) ]])
end) end)
@@ -311,18 +305,18 @@ describe('search highlighting', function()
feed('gg/^<cr>') feed('gg/^<cr>')
screen:expect([[ screen:expect([[
{2: } | {10: } |
{2:^ } | {10:^ } |
{2: } |*4 {10: } |*4
/^ | /^ |
]]) ]])
-- Test that highlights are preserved after moving the cursor. -- Test that highlights are preserved after moving the cursor.
feed('j') feed('j')
screen:expect([[ screen:expect([[
{2: } |*2 {10: } |*2
{2:^ } | {10:^ } |
{2: } |*3 {10: } |*3
/^ | /^ |
]]) ]])
@@ -332,17 +326,17 @@ describe('search highlighting', function()
feed('gg/^<cr>') feed('gg/^<cr>')
screen:expect([[ screen:expect([[
{2: }| {10: }|
{2:^ }| {10:^ }|
{2: }|*4 {10: }|*4
^/ | ^/ |
]]) ]])
feed('j') feed('j')
screen:expect([[ screen:expect([[
{2: }|*2 {10: }|*2
{2:^ }| {10:^ }|
{2: }|*3 {10: }|*3
^/ | ^/ |
]]) ]])
end) end)
@@ -367,19 +361,12 @@ describe('search highlighting', function()
bar baz foo bar baz foo
bar foo baz]]) bar foo baz]])
feed('/foo') feed('/foo')
screen:set_default_attr_ids({
[1] = { bold = true, foreground = Screen.colors.Blue },
[2] = { background = Screen.colors.Yellow }, -- Search
[3] = { reverse = true },
[4] = { bold = true, reverse = true },
[5] = { foreground = Screen.colors.White, background = Screen.colors.DarkGreen },
})
screen:expect([[ screen:expect([[
{3:foo} bar baz │{MATCH:%d+}: {2:foo}{MATCH:%s+}| {2:foo} bar baz │{MATCH:%d+}: {10:foo}{MATCH:%s+}|
bar baz {2:foo} │{MATCH:%d+}: {2:foo}{MATCH:%s+}| bar baz {10:foo} │{MATCH:%d+}: {10:foo}{MATCH:%s+}|
bar {2:foo} baz │{MATCH:%d+}: {2:foo}{MATCH:%s+}| bar {10:foo} baz │{MATCH:%d+}: {10:foo}{MATCH:%s+}|
{1:~ }│{MATCH:.*}|*2 {1:~ }│{MATCH:.*}|*2
{4:[No Name] [+] }{5:term }| {3:[No Name] [+] }{101:term }|
/foo^ | /foo^ |
]]) ]])
end) end)
@@ -394,8 +381,8 @@ describe('search highlighting', function()
command('vsplit') command('vsplit')
feed('gg/li') feed('gg/li')
screen:expect([[ screen:expect([[
the first {3:li}ne │the first {2:li}ne | the first {2:li}ne │the first {10:li}ne |
in a {2:li}ttle file │in a {2:li}ttle file | in a {10:li}ttle file │in a {10:li}ttle file |
{1:~ }│{1:~ }|*4 {1:~ }│{1:~ }|*4
/li^ | /li^ |
]]) ]])
@@ -403,16 +390,16 @@ describe('search highlighting', function()
-- check that consecutive matches are caught by C-g/C-t -- check that consecutive matches are caught by C-g/C-t
feed('<C-g>') feed('<C-g>')
screen:expect([[ screen:expect([[
the first {2:li}ne │the first {2:li}ne | the first {10:li}ne │the first {10:li}ne |
in a {3:li}ttle file │in a {2:li}ttle file | in a {2:li}ttle file │in a {10:li}ttle file |
{1:~ }│{1:~ }|*4 {1:~ }│{1:~ }|*4
/li^ | /li^ |
]]) ]])
feed('<C-t>') feed('<C-t>')
screen:expect([[ screen:expect([[
the first {3:li}ne │the first {2:li}ne | the first {2:li}ne │the first {10:li}ne |
in a {2:li}ttle file │in a {2:li}ttle file | in a {10:li}ttle file │in a {10:li}ttle file |
{1:~ }│{1:~ }|*4 {1:~ }│{1:~ }|*4
/li^ | /li^ |
]]) ]])
@@ -420,7 +407,7 @@ describe('search highlighting', function()
feed('t') feed('t')
screen:expect([[ screen:expect([[
the first line │the first line | the first line │the first line |
in a {3:lit}tle file │in a {2:lit}tle file | in a {2:lit}tle file │in a {10:lit}tle file |
{1:~ }│{1:~ }|*4 {1:~ }│{1:~ }|*4
/lit^ | /lit^ |
]]) ]])
@@ -428,14 +415,14 @@ describe('search highlighting', function()
feed('<cr>') feed('<cr>')
screen:expect([[ screen:expect([[
the first line │the first line | the first line │the first line |
in a {2:^lit}tle file │in a {2:lit}tle file | in a {10:^lit}tle file │in a {10:lit}tle file |
{1:~ }│{1:~ }|*4 {1:~ }│{1:~ }|*4
/lit | /lit |
]]) ]])
feed('/fir') feed('/fir')
screen:expect([[ screen:expect([[
the {3:fir}st line │the {2:fir}st line | the {2:fir}st line │the {10:fir}st line |
in a little file │in a little file | in a little file │in a little file |
{1:~ }│{1:~ }|*4 {1:~ }│{1:~ }|*4
/fir^ | /fir^ |
@@ -445,7 +432,7 @@ describe('search highlighting', function()
feed('<esc>/ttle') feed('<esc>/ttle')
screen:expect([[ screen:expect([[
the first line │the first line | the first line │the first line |
in a li{3:ttle} file │in a li{2:ttle} file | in a li{2:ttle} file │in a li{10:ttle} file |
{1:~ }│{1:~ }|*4 {1:~ }│{1:~ }|*4
/ttle^ | /ttle^ |
]]) ]])
@@ -454,7 +441,7 @@ describe('search highlighting', function()
feed('<esc>') feed('<esc>')
screen:expect([[ screen:expect([[
the first line │the first line | the first line │the first line |
in a {2:^lit}tle file │in a {2:lit}tle file | in a {10:^lit}tle file │in a {10:lit}tle file |
{1:~ }│{1:~ }|*4 {1:~ }│{1:~ }|*4
| |
]]) ]])
@@ -471,7 +458,7 @@ describe('search highlighting', function()
feed('/first') feed('/first')
screen:expect([[ screen:expect([[
the {3:first} line │the {2:first} line | the {2:first} line │the {10:first} line |
in a little file │in a little file | in a little file │in a little file |
{1:~ }│{1:~ }|*4 {1:~ }│{1:~ }|*4
/first^ | /first^ |
@@ -500,22 +487,22 @@ describe('search highlighting', function()
-- 8.0.1304, test that C-g and C-t works with incsearch and empty pattern -- 8.0.1304, test that C-g and C-t works with incsearch and empty pattern
feed('<esc>/fi<CR>') feed('<esc>/fi<CR>')
screen:expect([[ screen:expect([[
the {2:fi}rst line │the {2:fi}rst line | the {10:fi}rst line │the {10:fi}rst line |
in a little {2:^fi}le │in a little {2:fi}le | in a little {10:^fi}le │in a little {10:fi}le |
{1:~ }│{1:~ }|*4 {1:~ }│{1:~ }|*4
/fi | /fi |
]]) ]])
feed('//') feed('//')
screen:expect([[ screen:expect([[
the {3:fi}rst line │the {2:fi}rst line | the {2:fi}rst line │the {10:fi}rst line |
in a little {2:fi}le │in a little {2:fi}le | in a little {10:fi}le │in a little {10:fi}le |
{1:~ }│{1:~ }|*4 {1:~ }│{1:~ }|*4
//^ | //^ |
]]) ]])
feed('<C-g>') feed('<C-g>')
screen:expect([[ screen:expect([[
the {2:fi}rst line │the {2:fi}rst line | the {10:fi}rst line │the {10:fi}rst line |
in a little {3:fi}le │in a little {2:fi}le | in a little {2:fi}le │in a little {10:fi}le |
{1:~ }│{1:~ }|*4 {1:~ }│{1:~ }|*4
//^ | //^ |
]]) ]])
@@ -526,7 +513,7 @@ describe('search highlighting', function()
feed('/<C-R><C-R>"') feed('/<C-R><C-R>"')
screen:expect([[ screen:expect([[
the first line │the first line | the first line │the first line |
in a little {3:file} │in a little {2:file} | in a little {2:file} │in a little {10:file} |
{1:~ }│{1:~ }|*4 {1:~ }│{1:~ }|*4
/file^ | /file^ |
]]) ]])
@@ -538,7 +525,7 @@ describe('search highlighting', function()
command('let @* = "first"') command('let @* = "first"')
feed('/<C-R>*') feed('/<C-R>*')
screen:expect([[ screen:expect([[
the {3:first} line │the {2:first} line | the {2:first} line │the {10:first} line |
in a little file │in a little file | in a little file │in a little file |
{1:~ }│{1:~ }|*4 {1:~ }│{1:~ }|*4
/first^ | /first^ |
@@ -549,7 +536,7 @@ describe('search highlighting', function()
feed('/<C-R>+') feed('/<C-R>+')
screen:expect([[ screen:expect([[
the first line │the first line | the first line │the first line |
in a {3:little} file │in a {2:little} file | in a {2:little} file │in a {10:little} file |
{1:~ }│{1:~ }|*4 {1:~ }│{1:~ }|*4
/little^ | /little^ |
]]) ]])
@@ -565,8 +552,8 @@ describe('search highlighting', function()
feed('gg/mat/e') feed('gg/mat/e')
screen:expect([[ screen:expect([[
not the {3:mat}ch you're looking for | not the {2:mat}ch you're looking for |
the {2:mat}ch is here | the {10:mat}ch is here |
{1:~ }|*4 {1:~ }|*4
/mat/e^ | /mat/e^ |
]]) ]])
@@ -574,16 +561,16 @@ describe('search highlighting', function()
-- Search with count and /e offset fixed in Vim patch 7.4.532. -- Search with count and /e offset fixed in Vim patch 7.4.532.
feed('<esc>2/mat/e') feed('<esc>2/mat/e')
screen:expect([[ screen:expect([[
not the {2:mat}ch you're looking for | not the {10:mat}ch you're looking for |
the {3:mat}ch is here | the {2:mat}ch is here |
{1:~ }|*4 {1:~ }|*4
/mat/e^ | /mat/e^ |
]]) ]])
feed('<cr>') feed('<cr>')
screen:expect([[ screen:expect([[
not the {2:mat}ch you're looking for | not the {10:mat}ch you're looking for |
the {2:ma^t}ch is here | the {10:ma^t}ch is here |
{1:~ }|*4 {1:~ }|*4
/mat/e | /mat/e |
]]) ]])
@@ -595,37 +582,27 @@ describe('search highlighting', function()
feed('/line\\na<cr>') feed('/line\\na<cr>')
screen:expect([[ screen:expect([[
| |
a repeated {2:^line } | a repeated {10:^line } |
{2:a} repeated {2:line } |*2 {10:a} repeated {10:line } |*2
{2:a} repeated line | {10:a} repeated line |
{1:~ }| {1:~ }|
{4:search hit BOTTOM, continuing at TOP} | {19:search hit BOTTOM, continuing at TOP} |
]]) ]])
-- it redraws rows above the changed one -- it redraws rows above the changed one
feed('4Grb') feed('4Grb')
screen:expect([[ screen:expect([[
| |
a repeated {2:line } | a repeated {10:line } |
{2:a} repeated line | {10:a} repeated line |
^b repeated {2:line } | ^b repeated {10:line } |
{2:a} repeated line | {10:a} repeated line |
{1:~ }| {1:~ }|
{4:search hit BOTTOM, continuing at TOP} | {19:search hit BOTTOM, continuing at TOP} |
]]) ]])
end) end)
it('works with matchadd and syntax', function() it('works with matchadd and syntax', function()
screen:set_default_attr_ids {
[1] = { bold = true, foreground = Screen.colors.Blue },
[2] = { background = Screen.colors.Yellow },
[3] = { reverse = true },
[4] = { foreground = Screen.colors.Red },
[5] = { bold = true, background = Screen.colors.Green },
[6] = { italic = true, background = Screen.colors.Magenta },
[7] = { bold = true, background = Screen.colors.Yellow },
[8] = { foreground = Screen.colors.Blue4, background = Screen.colors.LightGray },
}
feed_command('set hlsearch') feed_command('set hlsearch')
insert [[ insert [[
very special text very special text
@@ -639,46 +616,31 @@ describe('search highlighting', function()
-- searchhl and matchadd matches are exclusive, only the highest priority -- searchhl and matchadd matches are exclusive, only the highest priority
-- is used (and matches with lower priorities are not combined) -- is used (and matches with lower priorities are not combined)
feed_command('/ial te') feed_command('/ial te')
screen:expect { screen:expect([[
grid = [[ very {102:spec^ial}{10: te}{103:xt} |
very {5:spec^ial}{2: te}{6:xt} |
| |
{1:~ }|*4 {1:~ }|*4
{4:search hit BOTTOM, continuing at TOP} | {19:search hit BOTTOM, continuing at TOP} |
]], ]])
win_viewport = {
[2] = {
win = 1000,
topline = 0,
botline = 3,
curline = 0,
curcol = 9,
linecount = 2,
sum_scroll_delta = 0,
},
},
}
-- check highlights work also in folds -- check highlights work also in folds
feed('zf4j') feed('zf4j')
screen:expect { screen:expect([[
grid = [[ {13:^+-- 2 lines: very special text·········}|
{8:^+-- 2 lines: very special text·········}|
{1:~ }|*5 {1:~ }|*5
{4:search hit BOTTOM, continuing at TOP} | {19:search hit BOTTOM, continuing at TOP} |
]], ]])
}
command('%foldopen') command('%foldopen')
screen:expect([[ screen:expect([[
very {5:spec^ial}{2: te}{6:xt} | very {102:spec^ial}{10: te}{103:xt} |
| |
{1:~ }|*4 {1:~ }|*4
{4:search hit BOTTOM, continuing at TOP} | {19:search hit BOTTOM, continuing at TOP} |
]]) ]])
feed_command('call clearmatches()') feed_command('call clearmatches()')
screen:expect([[ screen:expect([[
very spec{2:^ial te}xt | very spec{10:^ial te}xt |
| |
{1:~ }|*4 {1:~ }|*4
:call clearmatches() | :call clearmatches() |
@@ -688,7 +650,7 @@ describe('search highlighting', function()
-- nonconflicting attributes are combined -- nonconflicting attributes are combined
feed_command('syntax keyword MyGroup special') feed_command('syntax keyword MyGroup special')
screen:expect([[ screen:expect([[
very {5:spec}{7:^ial}{2: te}xt | very {102:spec}{104:^ial}{10: te}xt |
| |
{1:~ }|*4 {1:~ }|*4
:syntax keyword MyGroup special | :syntax keyword MyGroup special |
@@ -700,7 +662,7 @@ describe('search highlighting', function()
feed('ia/b/c<Esc>') feed('ia/b/c<Esc>')
feed(':%g@a/b') feed(':%g@a/b')
screen:expect([[ screen:expect([[
{3:a/b}/c | {2:a/b}/c |
{1:~ }|*5 {1:~ }|*5
:%g@a/b^ | :%g@a/b^ |
]]) ]])
@@ -711,7 +673,7 @@ describe('search highlighting', function()
feed('/foo<CR>/bar') feed('/foo<CR>/bar')
screen:expect([[ screen:expect([[
foo | foo |
{3:bar} | {2:bar} |
{1:~ }|*4 {1:~ }|*4
/bar^ | /bar^ |
]]) ]])
@@ -719,4 +681,19 @@ describe('search highlighting', function()
-- There is an intermediate state where :redraw! removes 'incsearch' highlight. -- There is an intermediate state where :redraw! removes 'incsearch' highlight.
screen:expect_unchanged(true) screen:expect_unchanged(true)
end) end)
it('highlight is not after redraw during substitute confirm prompt', function()
fn.setline(1, { 'foo', 'bar' })
command('set nohlsearch')
feed(':%s/bar/baz/c<CR>')
screen:try_resize(screen._width, screen._height - 1)
screen:expect([[
foo |
{2:bar} |
{1:~ }|
{3: }|
{6:replace with baz? (y)es/(n)o/(a)ll/(q)ui}|
{6:t/(l)ast/scroll up(^E)/down(^Y)}^ |
]])
end)
end) end)