aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2016-11-14 15:13:50 +0100
committerJustin M. Keyes <justinkz@gmail.com>2016-11-15 04:22:24 +0100
commit708617ebb6aa9f078549646930c73f0755c2c2e6 (patch)
treeac6b245b3d21d4472b8a004fa5d60e8f95182d24
parent91507c271e9e51cefed3dcac21f7a41b9cac0bbe (diff)
downloadrneovim-708617ebb6aa9f078549646930c73f0755c2c2e6.tar.gz
rneovim-708617ebb6aa9f078549646930c73f0755c2c2e6.tar.bz2
rneovim-708617ebb6aa9f078549646930c73f0755c2c2e6.zip
inccommand=nosplit: Jump to first match.
Call update_topline() to adjust the current viewport. Closes #5597
-rw-r--r--src/nvim/ex_cmds.c18
-rw-r--r--test/functional/ui/inccommand_spec.lua54
2 files changed, 22 insertions, 50 deletions
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index a747ead6b9..40e506e80e 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -6012,7 +6012,6 @@ static buf_T *show_sub(exarg_T *eap, pos_T old_cusr, char_u *pat, char_u *sub,
{
static handle_T bufnr = 0; // special buffer, re-used on each visit
- garray_T save_winsizes;
win_T *save_curwin = curwin;
cmdmod_T save_cmdmod = cmdmod;
char_u *save_shm_p = vim_strsave(p_shm);
@@ -6021,7 +6020,6 @@ static buf_T *show_sub(exarg_T *eap, pos_T old_cusr, char_u *pat, char_u *sub,
// We keep a special-purpose buffer around, but don't assume it exists.
buf_T *preview_buf = bufnr ? buflist_findnr(bufnr) : 0;
- win_size_save(&save_winsizes); // Save current window sizes.
cmdmod.tab = 0; // disable :tab modifier
cmdmod.noswapfile = true; // disable swap for preview buffer
// disable file info message
@@ -6100,20 +6098,18 @@ static buf_T *show_sub(exarg_T *eap, pos_T old_cusr, char_u *pat, char_u *sub,
}
redraw_later(SOME_VALID);
-
win_enter(save_curwin, false); // Return to original window
- win_size_restore(&save_winsizes);
- ga_clear(&save_winsizes);
-
- set_string_option_direct((char_u *)"shm", -1, save_shm_p, OPT_FREE, SID_NONE);
- xfree(save_shm_p);
+ update_topline();
// Update screen now. Must do this _before_ close_windows().
int save_rd = RedrawingDisabled;
RedrawingDisabled = 0;
- update_screen(NOT_VALID);
+ update_screen(SOME_VALID);
RedrawingDisabled = save_rd;
+ set_string_option_direct((char_u *)"shm", -1, save_shm_p, OPT_FREE, SID_NONE);
+ xfree(save_shm_p);
+
cmdmod = save_cmdmod;
return preview_buf;
@@ -6134,6 +6130,8 @@ void ex_substitute(exarg_T *eap)
block_autocmds(); // Disable events during command preview.
char_u *save_eap = eap->arg;
+ garray_T save_view;
+ win_size_save(&save_view); // Save current window sizes.
save_search_patterns();
int save_changedtick = curbuf->b_changedtick;
time_t save_b_u_time_cur = curbuf->b_u_time_cur;
@@ -6167,6 +6165,8 @@ void ex_substitute(exarg_T *eap)
curwin->w_p_cuc = save_w_p_cuc; // Restore 'cursorcolumn'
eap->arg = save_eap;
restore_search_patterns();
+ win_size_restore(&save_view);
+ ga_clear(&save_view);
emsg_off--;
unblock_autocmds();
}
diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua
index 7b6f82569a..811fee3a82 100644
--- a/test/functional/ui/inccommand_spec.lua
+++ b/test/functional/ui/inccommand_spec.lua
@@ -600,46 +600,18 @@ describe(":substitute, 'inccommand' preserves undo", function()
feed(":%s/tw/MO/g<esc>")
feed("u")
- if case == "split" then
- screen:expect([[
- ^LInc substitution on|
- two lines |
- |
- {15:~ }|
- {15:~ }|
- {15:~ }|
- {15:~ }|
- {15:~ }|
- {15:~ }|
- Already...st change |
- ]])
- elseif case == "" then
- screen:expect([[
- ^LInc substitution on|
- two lines |
- |
- {15:~ }|
- {15:~ }|
- {15:~ }|
- {15:~ }|
- {15:~ }|
- {15:~ }|
- Already...st change |
- ]])
- else
- screen:expect([[
- LInc substitution on|
- ^two lines |
- |
- {15:~ }|
- {15:~ }|
- {15:~ }|
- {15:~ }|
- {15:~ }|
- {15:~ }|
- Already...st change |
- ]])
- end
+ screen:expect([[
+ ^LInc substitution on|
+ two lines |
+ |
+ {15:~ }|
+ {15:~ }|
+ {15:~ }|
+ {15:~ }|
+ {15:~ }|
+ {15:~ }|
+ Already...st change |
+ ]])
end
screen:detach()
end)
@@ -905,11 +877,11 @@ describe(":substitute, inccommand=split", function()
feed(":%s/tw/X")
screen:expect([[
- Inc substitution on |
BBo lines |
Inc substitution on |
Xo lines |
Inc substitution on |
+ Xo lines |
{11:[No Name] [+] }|
|1001| {12:X}o lines |
|1003| {12:X}o lines |