mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:9.0.0457: substitute prompt does not highlight an empty match (#20186)
Problem: Substitute prompt does not highlight an empty match.
Solution: Highlight at least one character.
a04f457a6c
This commit is contained in:
parent
ec1f153ddc
commit
f19e91acd8
@ -3887,6 +3887,10 @@ static int do_sub(exarg_T *eap, proftime_T timeout, long cmdpreview_ns, handle_T
|
||||
- regmatch.startpos[0].lnum;
|
||||
search_match_endcol = regmatch.endpos[0].col
|
||||
+ len_change;
|
||||
if (search_match_lines == 0 && search_match_endcol == 0) {
|
||||
// highlight at least one character for /^/
|
||||
search_match_endcol = 1;
|
||||
}
|
||||
highlight_match = true;
|
||||
|
||||
update_topline(curwin);
|
||||
|
@ -1,6 +1,8 @@
|
||||
" Tests for the substitute (:s) command
|
||||
|
||||
source shared.vim
|
||||
source check.vim
|
||||
source screendump.vim
|
||||
|
||||
func Test_multiline_subst()
|
||||
enew!
|
||||
@ -668,6 +670,21 @@ func Test_sub_cmd_9()
|
||||
bw!
|
||||
endfunc
|
||||
|
||||
func Test_sub_highlight_zero_match()
|
||||
CheckRunVimInTerminal
|
||||
|
||||
let lines =<< trim END
|
||||
call setline(1, ['one', 'two', 'three'])
|
||||
END
|
||||
call writefile(lines, 'XscriptSubHighlight', 'D')
|
||||
let buf = RunVimInTerminal('-S XscriptSubHighlight', #{rows: 8, cols: 60})
|
||||
call term_sendkeys(buf, ":%s/^/ /c\<CR>")
|
||||
call VerifyScreenDump(buf, 'Test_sub_highlight_zer_match_1', {})
|
||||
|
||||
call term_sendkeys(buf, "\<Esc>")
|
||||
call StopVimInTerminal(buf)
|
||||
endfunc
|
||||
|
||||
func Test_nocatch_sub_failure_handling()
|
||||
" normal error results in all replacements
|
||||
func Foo()
|
||||
|
@ -3,11 +3,13 @@
|
||||
-- Test for *:s%* on :substitute.
|
||||
|
||||
local helpers = require('test.functional.helpers')(after_each)
|
||||
local Screen = require('test.functional.ui.screen')
|
||||
local feed, insert = helpers.feed, helpers.insert
|
||||
local exec = helpers.exec
|
||||
local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect
|
||||
local eq, eval = helpers.eq, helpers.eval
|
||||
|
||||
describe('substitue()', function()
|
||||
describe('substitute()', function()
|
||||
before_each(clear)
|
||||
|
||||
-- The original test contained several TEST_X lines to delimit different
|
||||
@ -132,7 +134,7 @@ describe('substitue()', function()
|
||||
end)
|
||||
end)
|
||||
|
||||
describe(':substitue', function()
|
||||
describe(':substitute', function()
|
||||
before_each(clear)
|
||||
|
||||
it('with \\ze and \\zs and confirmation dialog (TEST_8)', function()
|
||||
@ -159,4 +161,29 @@ describe(':substitue', function()
|
||||
feed('yyq') -- For the dialog of the previous :s command.
|
||||
expect('XXx')
|
||||
end)
|
||||
|
||||
it('first char is highlighted with confirmation dialog and empty match', function()
|
||||
local screen = Screen.new(60, 8)
|
||||
screen:set_default_attr_ids({
|
||||
[0] = {bold = true, foreground = Screen.colors.Blue}, -- NonText
|
||||
[1] = {reverse = true}, -- IncSearch
|
||||
[2] = {bold = true, foreground = Screen.colors.SeaGreen}, -- MoreMsg
|
||||
})
|
||||
screen:attach()
|
||||
exec([[
|
||||
set nohlsearch noincsearch
|
||||
call setline(1, ['one', 'two', 'three'])
|
||||
]])
|
||||
feed(':%s/^/ /c<CR>')
|
||||
screen:expect([[
|
||||
{1:o}ne |
|
||||
two |
|
||||
three |
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{2:replace with (y/n/a/q/l/^E/^Y)?}^ |
|
||||
]])
|
||||
end)
|
||||
end)
|
Loading…
Reference in New Issue
Block a user