mirror of
https://github.com/neovim/neovim.git
synced 2026-02-24 11:22:14 +10:00
vim-patch:9.1.2095: :wqall! doesn't quit when using :quit in BufWritePost
Problem: :wqall! doesn't quit when using :quit in BufWritePost
(after 8.0.1190).
Solution: Restore old value of "exiting" when calling not_exiting()
instead of always resetting it to FALSE (zeertzjq).
related: vim/vim#2205
closes: vim/vim#19212
e803ad1c56
This commit is contained in:
@@ -1878,6 +1878,7 @@ void do_wqall(exarg_T *eap)
|
|||||||
{
|
{
|
||||||
int error = 0;
|
int error = 0;
|
||||||
int save_forceit = eap->forceit;
|
int save_forceit = eap->forceit;
|
||||||
|
bool save_exiting = exiting;
|
||||||
|
|
||||||
if (eap->cmdidx == CMD_xall || eap->cmdidx == CMD_wqall) {
|
if (eap->cmdidx == CMD_xall || eap->cmdidx == CMD_wqall) {
|
||||||
if (before_quit_all(eap) == FAIL) {
|
if (before_quit_all(eap) == FAIL) {
|
||||||
@@ -1929,7 +1930,7 @@ void do_wqall(exarg_T *eap)
|
|||||||
if (!error) {
|
if (!error) {
|
||||||
getout(0); // exit Vim
|
getout(0); // exit Vim
|
||||||
}
|
}
|
||||||
not_exiting();
|
not_exiting(save_exiting);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4698,9 +4698,9 @@ static void ex_highlight(exarg_T *eap)
|
|||||||
|
|
||||||
/// Call this function if we thought we were going to exit, but we won't
|
/// Call this function if we thought we were going to exit, but we won't
|
||||||
/// (because of an error). May need to restore the terminal mode.
|
/// (because of an error). May need to restore the terminal mode.
|
||||||
void not_exiting(void)
|
void not_exiting(bool save_exiting)
|
||||||
{
|
{
|
||||||
exiting = false;
|
exiting = save_exiting;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool before_quit_autocmds(win_T *wp, bool quit_all, bool forceit)
|
bool before_quit_autocmds(win_T *wp, bool quit_all, bool forceit)
|
||||||
@@ -4770,6 +4770,7 @@ static void ex_quit(exarg_T *eap)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool save_exiting = exiting;
|
||||||
// If there is only one relevant window we will exit.
|
// If there is only one relevant window we will exit.
|
||||||
if (check_more(false, eap->forceit) == OK && only_one_window()) {
|
if (check_more(false, eap->forceit) == OK && only_one_window()) {
|
||||||
exiting = true;
|
exiting = true;
|
||||||
@@ -4780,7 +4781,7 @@ static void ex_quit(exarg_T *eap)
|
|||||||
| CCGD_EXCMD))
|
| CCGD_EXCMD))
|
||||||
|| check_more(true, eap->forceit) == FAIL
|
|| check_more(true, eap->forceit) == FAIL
|
||||||
|| (only_one_window() && check_changed_any(eap->forceit, true))) {
|
|| (only_one_window() && check_changed_any(eap->forceit, true))) {
|
||||||
not_exiting();
|
not_exiting(save_exiting);
|
||||||
} else {
|
} else {
|
||||||
// quit last window
|
// quit last window
|
||||||
// Note: only_one_window() returns true, even so a help window is
|
// Note: only_one_window() returns true, even so a help window is
|
||||||
@@ -4791,7 +4792,7 @@ static void ex_quit(exarg_T *eap)
|
|||||||
if (only_one_window() && (ONE_WINDOW || eap->addr_count == 0)) {
|
if (only_one_window() && (ONE_WINDOW || eap->addr_count == 0)) {
|
||||||
getout(0);
|
getout(0);
|
||||||
}
|
}
|
||||||
not_exiting();
|
not_exiting(save_exiting);
|
||||||
// close window; may free buffer
|
// close window; may free buffer
|
||||||
win_close(wp, !buf_hide(wp->w_buffer) || eap->forceit, eap->forceit);
|
win_close(wp, !buf_hide(wp->w_buffer) || eap->forceit, eap->forceit);
|
||||||
}
|
}
|
||||||
@@ -4837,11 +4838,12 @@ static void ex_quit_all(exarg_T *eap)
|
|||||||
if (before_quit_all(eap) == FAIL) {
|
if (before_quit_all(eap) == FAIL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
bool save_exiting = exiting;
|
||||||
exiting = true;
|
exiting = true;
|
||||||
if (eap->forceit || !check_changed_any(false, false)) {
|
if (eap->forceit || !check_changed_any(false, false)) {
|
||||||
getout(0);
|
getout(0);
|
||||||
}
|
}
|
||||||
not_exiting();
|
not_exiting(save_exiting);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ":close": close current window, unless it is the last one
|
/// ":close": close current window, unless it is the last one
|
||||||
@@ -5104,6 +5106,7 @@ static void ex_exit(exarg_T *eap)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool save_exiting = exiting;
|
||||||
// we plan to exit if there is only one relevant window
|
// we plan to exit if there is only one relevant window
|
||||||
if (check_more(false, eap->forceit) == OK && only_one_window()) {
|
if (check_more(false, eap->forceit) == OK && only_one_window()) {
|
||||||
exiting = true;
|
exiting = true;
|
||||||
@@ -5115,13 +5118,13 @@ static void ex_exit(exarg_T *eap)
|
|||||||
|| before_quit_autocmds(curwin, false, eap->forceit)
|
|| before_quit_autocmds(curwin, false, eap->forceit)
|
||||||
|| check_more(true, eap->forceit) == FAIL
|
|| check_more(true, eap->forceit) == FAIL
|
||||||
|| (only_one_window() && check_changed_any(eap->forceit, false))) {
|
|| (only_one_window() && check_changed_any(eap->forceit, false))) {
|
||||||
not_exiting();
|
not_exiting(save_exiting);
|
||||||
} else {
|
} else {
|
||||||
if (only_one_window()) {
|
if (only_one_window()) {
|
||||||
// quit last window, exit Vim
|
// quit last window, exit Vim
|
||||||
getout(0);
|
getout(0);
|
||||||
}
|
}
|
||||||
not_exiting();
|
not_exiting(save_exiting);
|
||||||
// Quit current window, may free the buffer.
|
// Quit current window, may free the buffer.
|
||||||
win_close(curwin, !buf_hide(curwin->w_buffer), eap->forceit);
|
win_close(curwin, !buf_hide(curwin->w_buffer), eap->forceit);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,6 +93,20 @@ func Test_exiting()
|
|||||||
call assert_equal(['QuitPre', 'ExitPre'], readfile('Xtestout'))
|
call assert_equal(['QuitPre', 'ExitPre'], readfile('Xtestout'))
|
||||||
endif
|
endif
|
||||||
call delete('Xtestout')
|
call delete('Xtestout')
|
||||||
|
|
||||||
|
" Test using :quit in BufWritePost during :wqall
|
||||||
|
let after =<< trim [CODE]
|
||||||
|
botright new Xwritebuf
|
||||||
|
call setline(1, 'SHOULD BE WRITTEN')
|
||||||
|
autocmd BufWritePost Xwritebuf 1quit
|
||||||
|
wqall
|
||||||
|
call setline(1, 'NOT REACHED') | write | qall
|
||||||
|
[CODE]
|
||||||
|
|
||||||
|
if RunVim([], after, '')
|
||||||
|
call assert_equal(['SHOULD BE WRITTEN'], readfile('Xwritebuf'))
|
||||||
|
endif
|
||||||
|
call delete('Xwritebuf')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Test for getting the Vim exit code from v:exiting
|
" Test for getting the Vim exit code from v:exiting
|
||||||
|
|||||||
Reference in New Issue
Block a user