fix(ui2): retain substitute confirmation highlight with nohlsearch #41067

Problem:
ui2 clears the substitute confirmation match when it updates its prompt buffer with hlsearch disabled.

Solution:
Only invalidate the match highlight when the current buffer changes.
This commit is contained in:
debaditya
2026-08-03 19:18:33 +05:30
committed by GitHub
parent 0aed30b4de
commit 6538d0aadb
2 changed files with 22 additions and 2 deletions

View File

@@ -142,8 +142,10 @@ void changed(buf_T *buf)
}
buf_inc_changedtick(buf);
// If a pattern is highlighted, the position may now be invalid.
Search.hl_match = false;
// A match highlight can only be invalidated by changes to the current buffer.
if (buf == curbuf) {
Search.hl_match = false;
}
}
/// Internal part of changed(), no user interaction.

View File

@@ -201,6 +201,24 @@ describe('cmdline2', function()
screen:expect_unchanged(true)
end)
it('keeps the confirmation match highlighted with nohlsearch #41039', function()
exec('call setline(1, "test test") | set nohlsearch')
feed('/te<CR>')
screen:expect([[
test ^test |
{1:~ }|*12
/te |
]])
feed(':%s/te/t/gc<CR>')
screen:expect([[
{2:te}st test |
{1:~ }|*11
{6:replace with t? (y)es/(n)o/(a)ll/(q)uit/(l)ast/scroll}|
{6: up(^E)/down(^Y)}^ |
]])
end)
it('dialog position is adjusted for toggled non-pum wildmenu', function()
exec([[
set wildmode=list:full,full wildoptions-=pum