mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
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
This commit is contained in:
parent
06f8ad5b2a
commit
26d08dfd0d
@ -3332,10 +3332,12 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout)
|
|||||||
sub = regtilde(sub, p_magic);
|
sub = regtilde(sub, p_magic);
|
||||||
|
|
||||||
// Check for a match on each line.
|
// Check for a match on each line.
|
||||||
|
// If preview: limit to max('cmdwinheight', viewport).
|
||||||
linenr_T line2 = eap->line2;
|
linenr_T line2 = eap->line2;
|
||||||
for (linenr_T lnum = eap->line1;
|
for (linenr_T lnum = eap->line1;
|
||||||
lnum <= line2 && !(got_quit || aborting())
|
lnum <= line2 && !got_quit && !aborting()
|
||||||
&& (!preview || matched_lines.size <= (size_t)p_cwh);
|
&& (!preview || matched_lines.size < (size_t)p_cwh
|
||||||
|
|| lnum <= curwin->w_botline);
|
||||||
lnum++) {
|
lnum++) {
|
||||||
long nmatch = vim_regexec_multi(®match, curwin, curbuf, lnum,
|
long nmatch = vim_regexec_multi(®match, curwin, curbuf, lnum,
|
||||||
(colnr_T)0, NULL);
|
(colnr_T)0, NULL);
|
||||||
|
@ -892,6 +892,31 @@ describe(":substitute, inccommand=split", function()
|
|||||||
]])
|
]])
|
||||||
end)
|
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()
|
it('actually replaces text', function()
|
||||||
feed(":%s/tw/XX/g<Enter>")
|
feed(":%s/tw/XX/g<Enter>")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user