STRCAT(t, newcmd);
if (ins_prevcmd)
STRCAT(t, prevcmd);
+ else
+ vim_free(t);
p = t + STRLEN(t);
STRCAT(t, trailarg);
vim_free(newcmd);
}
} 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)
+ // Don't clear "prevcmd" if there is no command to run.
+ if (STRLEN(newcmd) > 0)
{
- vim_free(newcmd);
- return;
+ vim_free(prevcmd);
+ prevcmd = newcmd;
}
- vim_free(prevcmd);
- prevcmd = newcmd;
-
if (bangredo) // put cmd in redo buffer for ! command
{
// If % or # appears in the command, it must have been escaped.
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'))