mirror of
https://github.com/neovim/neovim.git
synced 2026-01-26 22:56:04 +00:00
fix: make :restart respect 'confirm' option #36531
When 'confirm' is set and there are unsaved buffers, :restart now prompts before quitting, matching the behavior of :quit.
This commit is contained in:
@@ -4905,11 +4905,22 @@ static void ex_restart(exarg_T *eap)
|
||||
});
|
||||
set_vim_var_list(VV_ARGV, argv_cpy);
|
||||
}
|
||||
char *quit_cmd = (eap->do_ecmd_cmd) ? eap->do_ecmd_cmd : "qall!";
|
||||
Error err = ERROR_INIT;
|
||||
if ((cmdmod.cmod_flags & CMOD_CONFIRM) && check_changed_any(false, false)) {
|
||||
|
||||
bool confirm = (p_confirm || (cmdmod.cmod_flags & CMOD_CONFIRM));
|
||||
if (confirm && check_changed_any(false, false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
char *quit_cmd;
|
||||
if (eap->do_ecmd_cmd) {
|
||||
quit_cmd = eap->do_ecmd_cmd;
|
||||
} else if (confirm) {
|
||||
quit_cmd = "qall";
|
||||
} else {
|
||||
quit_cmd = "qall!";
|
||||
}
|
||||
|
||||
Error err = ERROR_INIT;
|
||||
restarting = true;
|
||||
nvim_command(cstr_as_string(quit_cmd), &err);
|
||||
if (ERROR_SET(&err)) {
|
||||
|
||||
@@ -378,6 +378,14 @@ describe('TUI :restart', function()
|
||||
tt.feed_data('C\013')
|
||||
screen:expect({ any = vim.pesc('[No Name]') })
|
||||
|
||||
-- Check :restart respects 'confirm' option.
|
||||
tt.feed_data(':set confirm\013')
|
||||
tt.feed_data(':restart\013')
|
||||
screen:expect({ any = vim.pesc('Save changes to "Untitled"?') })
|
||||
tt.feed_data('C\013')
|
||||
screen:expect({ any = vim.pesc('[No Name]') })
|
||||
tt.feed_data(':set noconfirm\013')
|
||||
|
||||
-- Check ":confirm restart <cmd>" on a modified buffer.
|
||||
tt.feed_data(':confirm restart echo "Hello"\013')
|
||||
screen:expect({ any = vim.pesc('Save changes to "Untitled"?') })
|
||||
|
||||
Reference in New Issue
Block a user