diff options
author | KillTheMule <KillTheMule@users.noreply.github.com> | 2017-08-28 21:33:31 +0200 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2017-09-09 15:02:06 +0200 |
commit | 26d08dfd0d9d2f8e3685a4fe083588519bd5dac0 (patch) | |
tree | 5a08faf29a68bebc2f360208172bba5efd478f5c | |
parent | 06f8ad5b2af59f61f053387d1347f6b1eada850e (diff) | |
download | rneovim-26d08dfd0d9d2f8e3685a4fe083588519bd5dac0.tar.gz rneovim-26d08dfd0d9d2f8e3685a4fe083588519bd5dac0.tar.bz2 rneovim-26d08dfd0d9d2f8e3685a4fe083588519bd5dac0.zip |
inccommand: fix optimization logic #7224
Before this change the preview changes in the buffer viewport were
limited to the size of the preview window ('cmdwinheight').
closes #7220
-rw-r--r-- | src/nvim/ex_cmds.c | 6 | ||||
-rw-r--r-- | test/functional/ui/inccommand_spec.lua | 25 |
2 files changed, 29 insertions, 2 deletions
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 32dbf4cc69..4b3e02e5fd 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -3332,10 +3332,12 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout) sub = regtilde(sub, p_magic); // Check for a match on each line. + // If preview: limit to max('cmdwinheight', viewport). linenr_T line2 = eap->line2; for (linenr_T lnum = eap->line1; - lnum <= line2 && !(got_quit || aborting()) - && (!preview || matched_lines.size <= (size_t)p_cwh); + lnum <= line2 && !got_quit && !aborting() + && (!preview || matched_lines.size < (size_t)p_cwh + || lnum <= curwin->w_botline); lnum++) { long nmatch = vim_regexec_multi(®match, curwin, curbuf, lnum, (colnr_T)0, NULL); diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua index 64965ccb94..e83bd72ad3 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -892,6 +892,31 @@ describe(":substitute, inccommand=split", function() ]]) end) + it('previews correctly when previewhight is small', function() + feed_command('set cwh=3') + feed_command('set hls') + feed('ggdG') + insert(string.rep('abc abc abc\n', 20)) + feed(':%s/abc/MMM/g') + screen:expect([[ + MMM MMM MMM | + MMM MMM MMM | + MMM MMM MMM | + MMM MMM MMM | + MMM MMM MMM | + MMM MMM MMM | + MMM MMM MMM | + MMM MMM MMM | + MMM MMM MMM | + {11:[No Name] [+] }| + | 1| {12:MMM} {12:MMM} {12:MMM} | + | 2| {12:MMM} {12:MMM} {12:MMM} | + | 3| {12:MMM} {12:MMM} {12:MMM} | + {10:[Preview] }| + :%s/abc/MMM/g^ | + ]]) + end) + it('actually replaces text', function() feed(":%s/tw/XX/g<Enter>") |