aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAufar Gilbran <aufargilbran@gmail.com>2020-08-11 00:47:50 +0800
committerAufar Gilbran <aufargilbran@gmail.com>2020-09-11 10:31:41 +0800
commit83f3218b286eb76e42c21dcd2ec7bec18683ead3 (patch)
treea8c030089e57ba4a17d3d670b1c64f51b33392e8 /src
parent50da4d4f451c24f53189a66b653236ac72cd2353 (diff)
downloadrneovim-83f3218b286eb76e42c21dcd2ec7bec18683ead3.tar.gz
rneovim-83f3218b286eb76e42c21dcd2ec7bec18683ead3.tar.bz2
rneovim-83f3218b286eb76e42c21dcd2ec7bec18683ead3.zip
vim-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 vim/vim#3321) https://github.com/vim/vim/commit/60d0871000e9abf3716ee035cba5b5a9d659e327
Diffstat (limited to 'src')
-rw-r--r--src/nvim/ex_getln.c10
-rw-r--r--src/nvim/testdir/test_search.vim6
2 files changed, 14 insertions, 2 deletions
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index d37075640d..a1a889d652 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -319,8 +319,14 @@ static bool do_incsearch_highlighting(int firstc, incsearch_state_T *s,
curwin->w_cursor = s->search_start;
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') {
// :s defaults to the current line
search_first_line = curwin->w_cursor.lnum;
diff --git a/src/nvim/testdir/test_search.vim b/src/nvim/testdir/test_search.vim
index c2093f47fd..c2584f99b9 100644
--- a/src/nvim/testdir/test_search.vim
+++ b/src/nvim/testdir/test_search.vim
@@ -637,6 +637,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)