neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 187ba3efce4acc197ce6cc9559a905eec97bacbe
parent 5b77dde8dd281b1db1f503d9b270c3697f88bd65
Author: zeertzjq <zeertzjq@outlook.com>
Date:   Tue, 18 Apr 2023 14:23:09 +0800

vim-patch:9.0.0815

https://github.com/vim/vim/commit/9c50eeb40117413bf59a9da904c8d0921ed0a6e6

Co-authored-by: Martin Tournoij <martin@arp242.net>

Diffstat:
Msrc/nvim/ex_cmds.c | 14++++++--------
Mtest/old/testdir/test_shell.vim | 4++--
2 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c @@ -988,6 +988,8 @@ void do_bang(int addr_count, exarg_T *eap, bool forceit, bool do_in, bool do_out } if (ins_prevcmd) { STRCAT(t, prevcmd); + } else { + xfree(t); } p = t + strlen(t); STRCAT(t, trailarg); @@ -1012,16 +1014,12 @@ void do_bang(int addr_count, exarg_T *eap, bool forceit, bool do_in, bool do_out } } while (trailarg != NULL); - // Don't do anything if there is no command as there isn't really anything - // useful in running "sh -c ''". Avoids changing "prevcmd". - if (strlen(newcmd) == 0) { - xfree(newcmd); - return; + // Don't clear "prevcmd" if there is no command to run. + if (strlen(newcmd) > 0) { + xfree(prevcmd); + prevcmd = newcmd; } - xfree(prevcmd); - prevcmd = newcmd; - if (bangredo) { // put cmd in redo buffer for ! command // If % or # appears in the command, it must have been escaped. // Reescape them, so that redoing them does not substitute them by the diff --git a/test/old/testdir/test_shell.vim b/test/old/testdir/test_shell.vim @@ -223,8 +223,8 @@ func Test_shell_repeat() call assert_equal(['Cmd: [-c echo coconut]'], readfile('Xlog')) call writefile(['empty'], 'Xlog') - call feedkeys(":!\<CR>", 'xt') " :! is a no-op - call assert_equal(['empty'], readfile('Xlog')) + call feedkeys(":!\<CR>", 'xt') " :! + call assert_equal(['Cmd: [-c ]'], readfile('Xlog')) call feedkeys(":!!\<CR>", 'xt') " :! doesn't clear previous command call assert_equal(['Cmd: [-c echo coconut]'], readfile('Xlog'))