diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-11-19 14:12:45 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-19 14:12:45 +0800 |
commit | c011747b5fc33eb7d9955c21d85085131ffaac0d (patch) | |
tree | 11edeb9c7e41db8e0e0123c379d24cda1d50f9d1 | |
parent | 92e51d7e4b79913434c7b74a275babcf65098b97 (diff) | |
download | rneovim-c011747b5fc33eb7d9955c21d85085131ffaac0d.tar.gz rneovim-c011747b5fc33eb7d9955c21d85085131ffaac0d.tar.bz2 rneovim-c011747b5fc33eb7d9955c21d85085131ffaac0d.zip |
vim-patch:8.2.5148: invalid memory access when using expression on command line (#21113)
Problem: Invalid memory access when using an expression on the command line.
Solution: Make sure the position does not go negative.
https://github.com/vim/vim/commit/6046aded8da002b08d380db29de2ba0268b6616e
N/A patches for version.c:
vim-patch:8.2.5149: cannot build without the +eval feature
Problem: Cannot build without the +eval feature. (Tony Mechelynck)
Solution: Add #ifdefs.
https://github.com/vim/vim/commit/6689df024bce4309ec5884e445738fe07ee4ffcc
Co-authored-by: Bram Moolenaar <Bram@vim.org>
-rw-r--r-- | src/nvim/ex_getln.c | 8 | ||||
-rw-r--r-- | src/nvim/testdir/test_cmdline.vim | 5 |
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() |