]> granicus.if.org Git - vim/commitdiff
patch 8.1.0291: 'incsearch' highlighting not used for :sort v8.1.0291
authorBram Moolenaar <Bram@vim.org>
Sat, 18 Aug 2018 14:19:42 +0000 (16:19 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 18 Aug 2018 14:19:42 +0000 (16:19 +0200)
Problem:    'incsearch' highlighting not used for :sort.
Solution:   Handle pattern in :sort command.

src/ex_getln.c
src/testdir/dumps/Test_incsearch_sort_01.dump [new file with mode: 0644]
src/testdir/test_search.vim
src/version.c

index d38fa4b0231a193fbb8c29da8ea1f53e7af1a607..7928af7bffd7a7227fe9f9be52d59c386c70bd98 100644 (file)
@@ -316,6 +316,7 @@ do_incsearch_highlighting(int firstc, incsearch_state_T *is_state,
                        && (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))
                {
@@ -331,6 +332,16 @@ do_incsearch_highlighting(int firstc, incsearch_state_T *is_state,
                        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;
+                   }
+
                    p = skipwhite(p);
                    delim = *p++;
                    end = skip_regexp(p, delim, p_magic, NULL);
@@ -359,7 +370,7 @@ do_incsearch_highlighting(int firstc, incsearch_state_T *is_state,
                                search_last_line = ea.line2;
                            }
                        }
-                       else if (*cmd == 's')
+                       else if (cmd[0] == 's' && cmd[1] != 'o')
                        {
                            // :s defaults to the current line
                            search_first_line = curwin->w_cursor.lnum;
diff --git a/src/testdir/dumps/Test_incsearch_sort_01.dump b/src/testdir/dumps/Test_incsearch_sort_01.dump
new file mode 100644 (file)
index 0000000..6c003af
--- /dev/null
@@ -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&|s|o|r|t| |n|i| |u| |/|o|n> @55
index 90a0a0e3b579eed472869507af17973105eef844..da388cd2e6482945c3594ed113229d38d81243a6 100644 (file)
@@ -917,6 +917,33 @@ func Test_incsearch_substitute_dump()
   call delete('Xis_subst_script')
 endfunc
 
+" Similar to Test_incsearch_substitute_dump() for :sort
+func Test_incsearch_ssort_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_sort_script')
+  let buf = RunVimInTerminal('-S Xis_sort_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, ':sort ni u /on')
+  sleep 100m
+  call VerifyScreenDump(buf, 'Test_incsearch_sort_01', {})
+  call term_sendkeys(buf, "\<Esc>")
+
+  call StopVimInTerminal(buf)
+  call delete('Xis_sort_script')
+endfunc
+
 func Test_search_undefined_behaviour()
   if !has("terminal")
     return
index 279908e04383f77bb389a7e93cfd6c2a49673f02..56ab4182d7028c41228015d897a1039c707a4e8f 100644 (file)
@@ -794,6 +794,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    291,
 /**/
     290,
 /**/