# HG changeset patch # User Christian Brabandt # Date 1534104005 -7200 # Node ID 60e0022e6e5d96015d1dc6e97d0aae4b82c0b151 # Parent 957961c9ff99c7c0dde14808f5be9010f9c7a297 patch 8.1.0278: 'incsearch' highlighting does not accept reverse range commit https://github.com/vim/vim/commit/60d0871000e9abf3716ee035cba5b5a9d659e327 Author: Bram Moolenaar Date: Sun Aug 12 21:53:15 2018 +0200 patch 8.1.0278: 'incsearch' highlighting does not accept reverse range Problem: 'incsearch' highlighting does not accept reverse range. Solution: Swap the range when needed. (issue https://github.com/vim/vim/issues/3321) diff --git a/src/ex_getln.c b/src/ex_getln.c --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -320,8 +320,17 @@ do_incsearch_highlighting(int firstc, in 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 --- /dev/null +++ b/src/testdir/dumps/Test_incsearch_substitute_04.dump @@ -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 diff --git a/src/testdir/test_search.vim b/src/testdir/test_search.vim --- a/src/testdir/test_search.vim +++ b/src/testdir/test_search.vim @@ -862,6 +862,12 @@ func Test_incsearch_substitute_dump() call term_sendkeys(buf, "\") sleep 100m call VerifyScreenDump(buf, 'Test_incsearch_substitute_03', {}) + call term_sendkeys(buf, "\") + + " Reverse range is accepted + call term_sendkeys(buf, ':5,2s/foo') + sleep 100m + call VerifyScreenDump(buf, 'Test_incsearch_substitute_04', {}) call term_sendkeys(buf, "\") call StopVimInTerminal(buf) diff --git a/src/version.c b/src/version.c --- 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 */ /**/ + 278, +/**/ 277, /**/ 276,