aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/ex_getln.c8
-rw-r--r--src/nvim/testdir/test_cmdline.vim5
2 files changed, 11 insertions, 2 deletions
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 0520c0e4a0..89d295e1a8 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -1613,6 +1613,8 @@ static int command_line_handle_key(CommandLineState *s)
return 0; // back to cmd mode
case Ctrl_R: { // insert register
+ const int save_new_cmdpos = new_cmdpos;
+
putcmdline('"', true);
no_mapping++;
allow_keys++;
@@ -1627,8 +1629,6 @@ static int command_line_handle_key(CommandLineState *s)
no_mapping--;
allow_keys--;
// Insert the result of an expression.
- // Need to save the current command line, to be able to enter
- // a new one...
new_cmdpos = -1;
if (s->c == '=') {
if (ccline.cmdfirstc == '=' // can't do this recursively
@@ -1660,8 +1660,12 @@ static int command_line_handle_key(CommandLineState *s)
}
}
}
+ new_cmdpos = save_new_cmdpos;
+
+ // remove the double quote
ccline.special_char = NUL;
redrawcmd();
+
return command_line_changed(s);
}
diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim
index 2921c8b41a..b9da4ca7bb 100644
--- a/src/nvim/testdir/test_cmdline.vim
+++ b/src/nvim/testdir/test_cmdline.vim
@@ -1850,6 +1850,11 @@ func Test_cmdline_expr()
call assert_equal("\"e \<C-\>\<C-Y>", @:)
endfunc
+" This was making the insert position negative
+func Test_cmdline_expr_register()
+ exe "sil! norm! ?\<C-\>e0\<C-R>0\<Esc>?\<C-\>e0\<CR>"
+endfunc
+
" Test for 'imcmdline' and 'imsearch'
" This test doesn't actually test the input method functionality.
func Test_cmdline_inputmethod()