diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-09-13 22:08:01 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-13 22:08:01 +0800 |
commit | f19e91acd8b90eaddaaa6070db260acf8de9aa10 (patch) | |
tree | 2e604d008e3e15955a559cce07e6d8550979d2ab /src | |
parent | ec1f153ddc58e38bf21e2a47b9621feb63fd0e51 (diff) | |
download | rneovim-f19e91acd8b90eaddaaa6070db260acf8de9aa10.tar.gz rneovim-f19e91acd8b90eaddaaa6070db260acf8de9aa10.tar.bz2 rneovim-f19e91acd8b90eaddaaa6070db260acf8de9aa10.zip |
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.
https://github.com/vim/vim/commit/a04f457a6c071179bac4088c9314007d39d5c5e0
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/ex_cmds.c | 4 | ||||
-rw-r--r-- | src/nvim/testdir/test_substitute.vim | 17 |
2 files changed, 21 insertions, 0 deletions
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 97080ad81d..2cc64918a3 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -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); diff --git a/src/nvim/testdir/test_substitute.vim b/src/nvim/testdir/test_substitute.vim index b3a80072d9..1667853575 100644 --- a/src/nvim/testdir/test_substitute.vim +++ b/src/nvim/testdir/test_substitute.vim @@ -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() |