aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorluukvbaal <luukvbaal@gmail.com>2025-03-28 19:48:17 +0100
committerGitHub <noreply@github.com>2025-03-28 19:48:17 +0100
commitf4ee0ab2f1a15fe3bb88122fa162620e4af74b1d (patch)
treee183940e47ca2454f331a7da9548a47f9c984a34
parent5554fcc28683e5d182198158b293851a96f0d6a0 (diff)
downloadrneovim-f4ee0ab2f1a15fe3bb88122fa162620e4af74b1d.tar.gz
rneovim-f4ee0ab2f1a15fe3bb88122fa162620e4af74b1d.tar.bz2
rneovim-f4ee0ab2f1a15fe3bb88122fa162620e4af74b1d.zip
fix(cmdline): avoid empty @: register after :<CR> (#33126)
Fix https://github.com/neovim/neovim/issues/33125
-rw-r--r--src/nvim/ex_docmd.c6
-rw-r--r--test/functional/ui/cmdline_spec.lua1
2 files changed, 5 insertions, 2 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index d76a28750b..746dc15c71 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -407,6 +407,7 @@ int do_cmdline(char *cmdline, LineGetter fgetline, void *cookie, int flags)
int count = 0; // line number count
bool did_inc = false; // incremented RedrawingDisabled
int block_indent = -1; // indent for ext_cmdline block event
+ char *block_line = NULL; // block_line for ext_cmdline block event
int retval = OK;
cstack_T cstack = { // conditional stack
.cs_idx = -1,
@@ -577,8 +578,9 @@ int do_cmdline(char *cmdline, LineGetter fgetline, void *cookie, int flags)
int indent = cstack.cs_idx < 0 ? 0 : (cstack.cs_idx + 1) * 2;
if (count >= 1 && getline_equal(fgetline, cookie, getexline)) {
if (ui_has(kUICmdline)) {
- char *line = last_cmdline ? last_cmdline : "";
+ char *line = block_line == last_cmdline ? "" : last_cmdline;
ui_ext_cmdline_block_append((size_t)MAX(0, block_indent), line);
+ block_line = last_cmdline;
block_indent = indent;
} else if (count == 1) {
// Need to set msg_didout for the first line after an ":if",
@@ -684,7 +686,7 @@ int do_cmdline(char *cmdline, LineGetter fgetline, void *cookie, int flags)
// If the command was typed, remember it for the ':' register.
// Do this AFTER executing the command to make :@: work.
- if (getline_equal(fgetline, cookie, getexline)) {
+ if (getline_equal(fgetline, cookie, getexline) && new_last_cmdline != NULL) {
xfree(last_cmdline);
last_cmdline = new_last_cmdline;
new_last_cmdline = NULL;
diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua
index 067be3b8d4..fb44c2ab52 100644
--- a/test/functional/ui/cmdline_spec.lua
+++ b/test/functional/ui/cmdline_spec.lua
@@ -900,6 +900,7 @@ local function test_cmdline(linegrid)
cmdline_block = { { { 'if 1' } }, { { ' let x = 1' } } },
})
feed('<CR>')
+ eq('let x = 1', eval('@:'))
screen:expect({
grid = s1,
cmdline = {