]> granicus.if.org Git - vim/commitdiff
patch 8.1.0278: 'incsearch' highlighting does not accept reverse range v8.1.0278
authorBram Moolenaar <Bram@vim.org>
Sun, 12 Aug 2018 19:53:15 +0000 (21:53 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 12 Aug 2018 19:53:15 +0000 (21:53 +0200)
Problem:    'incsearch' highlighting does not accept reverse range.
Solution:   Swap the range when needed. (issue #3321)

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

index a1cea9baf2ea50be84e75faf7bd947d0632443d6..22f35e1ecb213184ff5f8b434dda8da88db4f4b1 100644 (file)
@@ -320,8 +320,17 @@ do_incsearch_highlighting(int firstc, incsearch_state_T *is_state,
                        parse_cmd_address(&ea, &dummy);
                        if (ea.addr_count > 0)
                        {
-                           search_first_line = ea.line1;
-                           search_last_line = ea.line2;
+                           // Allow for reverse match.
+                           if (ea.line2 < ea.line1)
+                           {
+                               search_first_line = ea.line2;
+                               search_last_line = ea.line1;
+                           }
+                           else
+                           {
+                               search_first_line = ea.line1;
+                               search_last_line = ea.line2;
+                           }
                        }
                        else if (*cmd == 's')
                        {
diff --git a/src/testdir/dumps/Test_incsearch_substitute_04.dump b/src/testdir/dumps/Test_incsearch_substitute_04.dump
new file mode 100644 (file)
index 0000000..bae6c7b
--- /dev/null
@@ -0,0 +1,9 @@
+|f+0&#ffffff0|o@1| |1| @64
+|f+1&&|o@1| +0&&|2| @64
+|f+0&#ffff4012|o@1| +0&#ffffff0|3| @64
+|f+0&#ffff4012|o@1| +0&#ffffff0|4| @64
+|f+0&#ffff4012|o@1| +0&#ffffff0|5| @64
+|f|o@1| |6| @64
+|f|o@1| |7| @64
+|f|o@1| |8| @64
+|:|5|,|2|s|/|f|o@1> @60
index 9b701269d5fe56ee175fdef4521dc10c79f66d75..38e46cc85bdf1dc7c199af4c10645dca50db5b4a 100644 (file)
@@ -862,6 +862,12 @@ func Test_incsearch_substitute_dump()
   call term_sendkeys(buf, "\<BS>")
   sleep 100m
   call VerifyScreenDump(buf, 'Test_incsearch_substitute_03', {})
+  call term_sendkeys(buf, "\<Esc>")
+
+  " Reverse range is accepted
+  call term_sendkeys(buf, ':5,2s/foo')
+  sleep 100m
+  call VerifyScreenDump(buf, 'Test_incsearch_substitute_04', {})
 
   call term_sendkeys(buf, "\<Esc>")
   call StopVimInTerminal(buf)
index a3f81f072e6b38aaed37ac9d72fa8d8ed6723bdb..e1f2c6f2c87c1504c3e95c70cc822af1e5efaa66 100644 (file)
@@ -794,6 +794,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    278,
 /**/
     277,
 /**/