aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-02-05 12:13:21 +0800
committerGitHub <noreply@github.com>2024-02-05 12:13:21 +0800
commit35ffe58ea4a32719e6776f7b6ef710299f78342a (patch)
tree01f655d07aed2dd02afa897bc8250579d53535b1
parent18e62c1bdbbb6b93bfb74d974bc511fc4c03748e (diff)
downloadrneovim-35ffe58ea4a32719e6776f7b6ef710299f78342a.tar.gz
rneovim-35ffe58ea4a32719e6776f7b6ef710299f78342a.tar.bz2
rneovim-35ffe58ea4a32719e6776f7b6ef710299f78342a.zip
fix(inccommand): update topline after moving cursor (#27341)
-rw-r--r--src/nvim/ex_cmds.c6
-rw-r--r--test/functional/ui/inccommand_spec.lua2
2 files changed, 4 insertions, 4 deletions
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index 41d8e5d914..e265dc139a 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -4592,9 +4592,6 @@ static int show_sub(exarg_T *eap, pos_T old_cusr, PreviewLines *preview_lines, i
// disable file info message
set_string_option_direct(kOptShortmess, "F", 0, SID_NONE);
- // Update the topline to ensure that main window is on the correct line
- update_topline(curwin);
-
// Place cursor on nearest matching line, to undo do_sub() cursor placement.
for (size_t i = 0; i < lines.subresults.size; i++) {
SubResult curres = lines.subresults.items[i];
@@ -4605,6 +4602,9 @@ static int show_sub(exarg_T *eap, pos_T old_cusr, PreviewLines *preview_lines, i
} // Else: All matches are above, do_sub() already placed cursor.
}
+ // Update the topline to ensure that main window is on the correct line
+ update_topline(curwin);
+
// Width of the "| lnum|..." column which displays the line numbers.
int col_width = 0;
// Use preview window only when inccommand=split and range is not just the current line
diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua
index 7e79479fc5..29c8c43ca1 100644
--- a/test/functional/ui/inccommand_spec.lua
+++ b/test/functional/ui/inccommand_spec.lua
@@ -1064,11 +1064,11 @@ describe(':substitute, inccommand=split', function()
feed(':%s/tw/X')
screen:expect([[
+ Inc substitution on |
BBo lines |
Inc substitution on |
{12:X}o lines |
Inc substitution on |
- {12:X}o lines |
{11:[No Name] [+] }|
|1001| {12:X}o lines |
|1003| {12:X}o lines |