summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-08-18 21:05:31 +0200
committerBram Moolenaar <Bram@vim.org>2018-08-18 21:05:31 +0200
commit264cf5cfaf40e704aea2578e70c15ed9a9d0161e (patch)
tree0cc382c062de9fd17d9a8228829c526a03674973
parent3b9fcfcffab8f927a01877804fa6ac5bbca34c7a (diff)
patch 8.1.0295: no 'incsearch' highlighting for :vimgrep and similarv8.1.0295
Problem: No 'incsearch' highlighting for :vimgrep and similar commands. Solution: Parse the :vimgrep command and similar ones to locate the search pattern. (Hirohito Higashi, closes #3344)
-rw-r--r--src/ex_getln.c80
-rw-r--r--src/testdir/dumps/Test_incsearch_vimgrep_01.dump9
-rw-r--r--src/testdir/dumps/Test_incsearch_vimgrep_02.dump9
-rw-r--r--src/testdir/dumps/Test_incsearch_vimgrep_03.dump9
-rw-r--r--src/testdir/dumps/Test_incsearch_vimgrep_04.dump9
-rw-r--r--src/testdir/dumps/Test_incsearch_vimgrep_05.dump9
-rw-r--r--src/testdir/test_search.vim47
-rw-r--r--src/version.c2
8 files changed, 146 insertions, 28 deletions
diff --git a/src/ex_getln.c b/src/ex_getln.c
index 7928af7bff..bce4aac790 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -307,49 +307,73 @@ do_incsearch_highlighting(int firstc, incsearch_state_T *is_state,
cmdmod = save_cmdmod;
cmd = skip_range(ea.cmd, NULL);
- if (*cmd == 's' || *cmd == 'g' || *cmd == 'v')
+ if (*cmd == 's' || *cmd == 'g' || *cmd == 'v' || *cmd == 'l')
{
// Skip over "substitute" to find the pattern separator.
for (p = cmd; ASCII_ISALPHA(*p); ++p)
;
- if (*skipwhite(p) != NUL
- && (STRNCMP(cmd, "substitute", p - cmd) == 0
- || STRNCMP(cmd, "smagic", p - cmd) == 0
- || STRNCMP(cmd, "snomagic", MAX(p - cmd, 3)) == 0
- || STRNCMP(cmd, "sort", p - cmd) == 0
- || STRNCMP(cmd, "global", p - cmd) == 0
- || STRNCMP(cmd, "vglobal", p - cmd) == 0))
+ if (*skipwhite(p) != NUL)
{
- if (*cmd == 's' && cmd[1] == 'm')
- p_magic = TRUE;
- else if (*cmd == 's' && cmd[1] == 'n')
- p_magic = FALSE;
+ if (STRNCMP(cmd, "substitute", p - cmd) == 0
+ || STRNCMP(cmd, "smagic", p - cmd) == 0
+ || STRNCMP(cmd, "snomagic", MAX(p - cmd, 3)) == 0
+ || STRNCMP(cmd, "sort", MAX(p - cmd, 3)) == 0
+ || STRNCMP(cmd, "global", p - cmd) == 0
+ || STRNCMP(cmd, "vglobal", p - cmd) == 0)
+ {
+ if (*cmd == 's' && cmd[1] == 'm')
+ p_magic = TRUE;
+ else if (*cmd == 's' && cmd[1] == 'n')
+ p_magic = FALSE;
+
+ // Check for "global!/".
+ if (*cmd == 'g' && *p == '!')
+ {
+ p++;
+ if (*skipwhite(p) == NUL)
+ return FALSE;
+ }
+
+ // For ":sort" skip over flags.
+ if (cmd[0] == 's' && cmd[1] == 'o')
+ {
+ while (ASCII_ISALPHA(*(p = skipwhite(p))))
+ ++p;
+ if (*p == NUL)
+ return FALSE;
+ }
- // Check for "global!/".
- if (*cmd == 'g' && *p == '!')
+ p = skipwhite(p);
+ delim = *p++;
+ end = skip_regexp(p, delim, p_magic, NULL);
+ }
+ else if (STRNCMP(cmd, "vimgrep", MAX(p - cmd, 3)) == 0
+ || STRNCMP(cmd, "vimgrepadd", MAX(p - cmd, 8)) == 0
+ || STRNCMP(cmd, "lvimgrep", MAX(p - cmd, 2)) == 0
+ || STRNCMP(cmd, "lvimgrepadd", MAX(p - cmd, 9)) == 0)
{
- p++;
- if (*skipwhite(p) == NUL)
- return FALSE;
+ // Check for "!/".
+ if (*p == '!')
+ {
+ p++;
+ if (*skipwhite(p) == NUL)
+ return FALSE;
+ }
+ p = skipwhite(p);
+ delim = (vim_isIDc(*p)) ? ' ' : *p++;
+ end = skip_regexp(p, delim, p_magic, NULL);
}
-
- // For ":sort" skip over flags.
- if (cmd[0] == 's' && cmd[1] == 'o')
+ else
{
- while (ASCII_ISALPHA(*(p = skipwhite(p))))
- ++p;
- if (*p == NUL)
- return FALSE;
+ end = p;
+ delim = -1;
}
- p = skipwhite(p);
- delim = *p++;
- end = skip_regexp(p, delim, p_magic, NULL);
if (end > p || *end == delim)
{
pos_T save_cursor = curwin->w_cursor;
- // found a non-empty pattern
+ // found a non-empty pattern or //
*skiplen = (int)(p - ccline.cmdbuff);
*patlen = (int)(end - p);
diff --git a/src/testdir/dumps/Test_incsearch_vimgrep_01.dump b/src/testdir/dumps/Test_incsearch_vimgrep_01.dump
new file mode 100644
index 0000000000..955d030583
--- /dev/null
+++ b/src/testdir/dumps/Test_incsearch_vimgrep_01.dump
@@ -0,0 +1,9 @@
+|a+0&#ffffff0|n|o|t|h|e|r| |o+1&&|n|e+0&&| |2| @56
+|t|h|a|t| |o+0&#ffff4012|n|e+0&#ffffff0| |3| @59
+|t|h|e| |o+0&#ffff4012|n|e+0&#ffffff0| |1| @60
+|~+0#4040ff13&| @68
+|~| @68
+|~| @68
+|~| @68
+|~| @68
+|:+0#0000000&|v|i|m|g|r|e|p| |o|n> @58
diff --git a/src/testdir/dumps/Test_incsearch_vimgrep_02.dump b/src/testdir/dumps/Test_incsearch_vimgrep_02.dump
new file mode 100644
index 0000000000..a5d94eac55
--- /dev/null
+++ b/src/testdir/dumps/Test_incsearch_vimgrep_02.dump
@@ -0,0 +1,9 @@
+|a+0&#ffffff0|n|o|t|h|e|r| |o+1&&|n|e+0&&| |2| @56
+|t|h|a|t| |o+0&#ffff4012|n|e+0&#ffffff0| |3| @59
+|t|h|e| |o+0&#ffff4012|n|e+0&#ffffff0| |1| @60
+|~+0#4040ff13&| @68
+|~| @68
+|~| @68
+|~| @68
+|~| @68
+|:+0#0000000&|v|i|m|g| |/|o|n|/| |*|.|t|x|t> @53
diff --git a/src/testdir/dumps/Test_incsearch_vimgrep_03.dump b/src/testdir/dumps/Test_incsearch_vimgrep_03.dump
new file mode 100644
index 0000000000..038ceb9d95
--- /dev/null
+++ b/src/testdir/dumps/Test_incsearch_vimgrep_03.dump
@@ -0,0 +1,9 @@
+|a+0&#ffffff0|n|o|t|h|e|r| |o+1&&|n|e+0&&| |2| @56
+|t|h|a|t| |o+0&#ffff4012|n|e+0&#ffffff0| |3| @59
+|t|h|e| |o+0&#ffff4012|n|e+0&#ffffff0| |1| @60
+|~+0#4040ff13&| @68
+|~| @68
+|~| @68
+|~| @68
+|~| @68
+|:+0#0000000&|v|i|m|g|r|e|p|a|d@1| |"|\|<|o|n> @52
diff --git a/src/testdir/dumps/Test_incsearch_vimgrep_04.dump b/src/testdir/dumps/Test_incsearch_vimgrep_04.dump
new file mode 100644
index 0000000000..92dd78dd87
--- /dev/null
+++ b/src/testdir/dumps/Test_incsearch_vimgrep_04.dump
@@ -0,0 +1,9 @@
+|a+0&#ffffff0|n|o|t|h|e|r| |o|n|e| |2| @56
+|t+1&&|h|a|t+0&&| |o|n|e| |3| @59
+|t|h|e| |o|n|e| |1| @60
+|~+0#4040ff13&| @68
+|~| @68
+|~| @68
+|~| @68
+|~| @68
+|:+0#0000000&|l|v| |"|t|h|a> @61
diff --git a/src/testdir/dumps/Test_incsearch_vimgrep_05.dump b/src/testdir/dumps/Test_incsearch_vimgrep_05.dump
new file mode 100644
index 0000000000..e11ff574c1
--- /dev/null
+++ b/src/testdir/dumps/Test_incsearch_vimgrep_05.dump
@@ -0,0 +1,9 @@
+|a+0&#ffffff0|n|o|t+1&&|h|e|r+0&&| |o|n|e| |2| @56
+|t|h|a|t| |o|n|e| |3| @59
+|t+0&#ffff4012|h|e| +0&#ffffff0|o|n|e| |1| @60
+|~+0#4040ff13&| @68
+|~| @68
+|~| @68
+|~| @68
+|~| @68
+|:+0#0000000&|l|v|i|m|g|r|e|p|a| |"|t|h|e|"| |*@1|/|*|.|t|x|t> @44
diff --git a/src/testdir/test_search.vim b/src/testdir/test_search.vim
index da388cd2e6..9ede26dd3e 100644
--- a/src/testdir/test_search.vim
+++ b/src/testdir/test_search.vim
@@ -944,6 +944,53 @@ func Test_incsearch_ssort_dump()
call delete('Xis_sort_script')
endfunc
+" Similar to Test_incsearch_substitute_dump() for :vimgrep famiry
+func Test_incsearch_vimgrep_dump()
+ if !exists('+incsearch')
+ return
+ endif
+ if !CanRunVimInTerminal()
+ return
+ endif
+ call writefile([
+ \ 'set incsearch hlsearch scrolloff=0',
+ \ 'call setline(1, ["another one 2", "that one 3", "the one 1"])',
+ \ ], 'Xis_vimgrep_script')
+ let buf = RunVimInTerminal('-S Xis_vimgrep_script', {'rows': 9, 'cols': 70})
+ " Give Vim a chance to redraw to get rid of the spaces in line 2 caused by
+ " the 'ambiwidth' check.
+ sleep 100m
+
+ " Need to send one key at a time to force a redraw.
+ call term_sendkeys(buf, ':vimgrep on')
+ sleep 100m
+ call VerifyScreenDump(buf, 'Test_incsearch_vimgrep_01', {})
+ call term_sendkeys(buf, "\<Esc>")
+
+ call term_sendkeys(buf, ':vimg /on/ *.txt')
+ sleep 100m
+ call VerifyScreenDump(buf, 'Test_incsearch_vimgrep_02', {})
+ call term_sendkeys(buf, "\<Esc>")
+
+ call term_sendkeys(buf, ':vimgrepadd "\<on')
+ sleep 100m
+ call VerifyScreenDump(buf, 'Test_incsearch_vimgrep_03', {})
+ call term_sendkeys(buf, "\<Esc>")
+
+ call term_sendkeys(buf, ':lv "tha')
+ sleep 100m
+ call VerifyScreenDump(buf, 'Test_incsearch_vimgrep_04', {})
+ call term_sendkeys(buf, "\<Esc>")
+
+ call term_sendkeys(buf, ':lvimgrepa "the" **/*.txt')
+ sleep 100m
+ call VerifyScreenDump(buf, 'Test_incsearch_vimgrep_05', {})
+ call term_sendkeys(buf, "\<Esc>")
+
+ call StopVimInTerminal(buf)
+ call delete('Xis_vimgrep_script')
+endfunc
+
func Test_search_undefined_behaviour()
if !has("terminal")
return
diff --git a/src/version.c b/src/version.c
index 8cf1ad45f4..a084de0488 100644
--- a/src/version.c
+++ b/src/version.c
@@ -795,6 +795,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 295,
+/**/
294,
/**/
293,