mirror of
https://github.com/neovim/neovim.git
synced 2024-12-20 19:25:11 -07:00
vim-patch:8.0.0858: can exit while a terminal is still running a job
Problem: Can exit while a terminal is still running a job.
Solution: Consider a buffer with a running job like a changed file.
eb44a68b42
This commit is contained in:
parent
3ffeceb851
commit
2929dbf223
@ -1411,7 +1411,7 @@ void set_curbuf(buf_T *buf, int action)
|
|||||||
u_sync(FALSE);
|
u_sync(FALSE);
|
||||||
close_buffer(prevbuf == curwin->w_buffer ? curwin : NULL, prevbuf,
|
close_buffer(prevbuf == curwin->w_buffer ? curwin : NULL, prevbuf,
|
||||||
unload ? action : (action == DOBUF_GOTO
|
unload ? action : (action == DOBUF_GOTO
|
||||||
&& !P_HID(prevbuf)
|
&& !buf_hide(prevbuf)
|
||||||
&& !bufIsChanged(
|
&& !bufIsChanged(
|
||||||
prevbuf)) ? DOBUF_UNLOAD : 0, FALSE);
|
prevbuf)) ? DOBUF_UNLOAD : 0, FALSE);
|
||||||
if (curwin != previouswin && win_valid(previouswin))
|
if (curwin != previouswin && win_valid(previouswin))
|
||||||
@ -4414,11 +4414,11 @@ do_arg_all (
|
|||||||
wp->w_arg_idx = i;
|
wp->w_arg_idx = i;
|
||||||
|
|
||||||
if (i == opened_len && !keep_tabs) { /* close this window */
|
if (i == opened_len && !keep_tabs) { /* close this window */
|
||||||
if (P_HID(buf) || forceit || buf->b_nwindows > 1
|
if (buf_hide(buf) || forceit || buf->b_nwindows > 1
|
||||||
|| !bufIsChanged(buf)) {
|
|| !bufIsChanged(buf)) {
|
||||||
/* If the buffer was changed, and we would like to hide it,
|
/* If the buffer was changed, and we would like to hide it,
|
||||||
* try autowriting. */
|
* try autowriting. */
|
||||||
if (!P_HID(buf) && buf->b_nwindows <= 1 && bufIsChanged(buf)) {
|
if (!buf_hide(buf) && buf->b_nwindows <= 1 && bufIsChanged(buf)) {
|
||||||
bufref_T bufref;
|
bufref_T bufref;
|
||||||
set_bufref(&bufref, buf);
|
set_bufref(&bufref, buf);
|
||||||
(void)autowrite(buf, false);
|
(void)autowrite(buf, false);
|
||||||
@ -4433,7 +4433,7 @@ do_arg_all (
|
|||||||
&& (first_tabpage->tp_next == NULL || !had_tab)) {
|
&& (first_tabpage->tp_next == NULL || !had_tab)) {
|
||||||
use_firstwin = true;
|
use_firstwin = true;
|
||||||
} else {
|
} else {
|
||||||
win_close(wp, !P_HID(buf) && !bufIsChanged(buf));
|
win_close(wp, !buf_hide(buf) && !bufIsChanged(buf));
|
||||||
// check if autocommands removed the next window
|
// check if autocommands removed the next window
|
||||||
if (!win_valid(wpnext)) {
|
if (!win_valid(wpnext)) {
|
||||||
// start all over...
|
// start all over...
|
||||||
@ -4513,7 +4513,7 @@ do_arg_all (
|
|||||||
}
|
}
|
||||||
(void)do_ecmd(0, alist_name(&AARGLIST(alist)[i]), NULL, NULL,
|
(void)do_ecmd(0, alist_name(&AARGLIST(alist)[i]), NULL, NULL,
|
||||||
ECMD_ONE,
|
ECMD_ONE,
|
||||||
((P_HID(curwin->w_buffer)
|
((buf_hide(curwin->w_buffer)
|
||||||
|| bufIsChanged(curwin->w_buffer)) ? ECMD_HIDE : 0)
|
|| bufIsChanged(curwin->w_buffer)) ? ECMD_HIDE : 0)
|
||||||
+ ECMD_OLDBUF, curwin);
|
+ ECMD_OLDBUF, curwin);
|
||||||
if (use_firstwin)
|
if (use_firstwin)
|
||||||
@ -4705,13 +4705,13 @@ void ex_buffer_all(exarg_T *eap)
|
|||||||
* Close superfluous windows.
|
* Close superfluous windows.
|
||||||
*/
|
*/
|
||||||
for (wp = lastwin; open_wins > count; ) {
|
for (wp = lastwin; open_wins > count; ) {
|
||||||
r = (P_HID(wp->w_buffer) || !bufIsChanged(wp->w_buffer)
|
r = (buf_hide(wp->w_buffer) || !bufIsChanged(wp->w_buffer)
|
||||||
|| autowrite(wp->w_buffer, FALSE) == OK);
|
|| autowrite(wp->w_buffer, FALSE) == OK);
|
||||||
if (!win_valid(wp)) {
|
if (!win_valid(wp)) {
|
||||||
/* BufWrite Autocommands made the window invalid, start over */
|
/* BufWrite Autocommands made the window invalid, start over */
|
||||||
wp = lastwin;
|
wp = lastwin;
|
||||||
} else if (r) {
|
} else if (r) {
|
||||||
win_close(wp, !P_HID(wp->w_buffer));
|
win_close(wp, !buf_hide(wp->w_buffer));
|
||||||
--open_wins;
|
--open_wins;
|
||||||
wp = lastwin;
|
wp = lastwin;
|
||||||
} else {
|
} else {
|
||||||
|
@ -2015,7 +2015,7 @@ int getfile(int fnum, char_u *ffname, char_u *sfname, int setpm, linenr_T lnum,
|
|||||||
|
|
||||||
if (other)
|
if (other)
|
||||||
++no_wait_return; /* don't wait for autowrite message */
|
++no_wait_return; /* don't wait for autowrite message */
|
||||||
if (other && !forceit && curbuf->b_nwindows == 1 && !P_HID(curbuf)
|
if (other && !forceit && curbuf->b_nwindows == 1 && !buf_hide(curbuf)
|
||||||
&& curbufIsChanged() && autowrite(curbuf, forceit) == FAIL) {
|
&& curbufIsChanged() && autowrite(curbuf, forceit) == FAIL) {
|
||||||
if (p_confirm && p_write)
|
if (p_confirm && p_write)
|
||||||
dialog_changed(curbuf, FALSE);
|
dialog_changed(curbuf, FALSE);
|
||||||
@ -2038,7 +2038,7 @@ int getfile(int fnum, char_u *ffname, char_u *sfname, int setpm, linenr_T lnum,
|
|||||||
beginline(BL_SOL | BL_FIX);
|
beginline(BL_SOL | BL_FIX);
|
||||||
retval = 0; /* it's in the same file */
|
retval = 0; /* it's in the same file */
|
||||||
} else if (do_ecmd(fnum, ffname, sfname, NULL, lnum,
|
} else if (do_ecmd(fnum, ffname, sfname, NULL, lnum,
|
||||||
(P_HID(curbuf) ? ECMD_HIDE : 0) + (forceit ? ECMD_FORCEIT : 0),
|
(buf_hide(curbuf) ? ECMD_HIDE : 0) + (forceit ? ECMD_FORCEIT : 0),
|
||||||
curwin) == OK)
|
curwin) == OK)
|
||||||
retval = -1; /* opened another file */
|
retval = -1; /* opened another file */
|
||||||
else
|
else
|
||||||
|
@ -1343,7 +1343,7 @@ void dialog_changed(buf_T *buf, int checkall)
|
|||||||
/// hidden, autowriting it or unloading it.
|
/// hidden, autowriting it or unloading it.
|
||||||
bool can_abandon(buf_T *buf, int forceit)
|
bool can_abandon(buf_T *buf, int forceit)
|
||||||
{
|
{
|
||||||
return P_HID(buf)
|
return buf_hide(buf)
|
||||||
|| !bufIsChanged(buf)
|
|| !bufIsChanged(buf)
|
||||||
|| buf->b_nwindows > 1
|
|| buf->b_nwindows > 1
|
||||||
|| autowrite(buf, forceit) == OK
|
|| autowrite(buf, forceit) == OK
|
||||||
@ -1860,12 +1860,12 @@ void do_argfile(exarg_T *eap, int argn)
|
|||||||
// if 'hidden' set, only check for changed file when re-editing
|
// if 'hidden' set, only check for changed file when re-editing
|
||||||
// the same buffer
|
// the same buffer
|
||||||
other = true;
|
other = true;
|
||||||
if (P_HID(curbuf)) {
|
if (buf_hide(curbuf)) {
|
||||||
p = (char_u *)fix_fname((char *)alist_name(&ARGLIST[argn]));
|
p = (char_u *)fix_fname((char *)alist_name(&ARGLIST[argn]));
|
||||||
other = otherfile(p);
|
other = otherfile(p);
|
||||||
xfree(p);
|
xfree(p);
|
||||||
}
|
}
|
||||||
if ((!P_HID(curbuf) || !other)
|
if ((!buf_hide(curbuf) || !other)
|
||||||
&& check_changed(curbuf, CCGD_AW
|
&& check_changed(curbuf, CCGD_AW
|
||||||
| (other ? 0 : CCGD_MULTWIN)
|
| (other ? 0 : CCGD_MULTWIN)
|
||||||
| (eap->forceit ? CCGD_FORCEIT : 0)
|
| (eap->forceit ? CCGD_FORCEIT : 0)
|
||||||
@ -1885,7 +1885,7 @@ void do_argfile(exarg_T *eap, int argn)
|
|||||||
// argument index.
|
// argument index.
|
||||||
if (do_ecmd(0, alist_name(&ARGLIST[curwin->w_arg_idx]), NULL,
|
if (do_ecmd(0, alist_name(&ARGLIST[curwin->w_arg_idx]), NULL,
|
||||||
eap, ECMD_LAST,
|
eap, ECMD_LAST,
|
||||||
(P_HID(curwin->w_buffer) ? ECMD_HIDE : 0)
|
(buf_hide(curwin->w_buffer) ? ECMD_HIDE : 0)
|
||||||
+ (eap->forceit ? ECMD_FORCEIT : 0), curwin) == FAIL) {
|
+ (eap->forceit ? ECMD_FORCEIT : 0), curwin) == FAIL) {
|
||||||
curwin->w_arg_idx = old_arg_idx;
|
curwin->w_arg_idx = old_arg_idx;
|
||||||
} else if (eap->cmdidx != CMD_argdo) {
|
} else if (eap->cmdidx != CMD_argdo) {
|
||||||
@ -1902,7 +1902,7 @@ void ex_next(exarg_T *eap)
|
|||||||
|
|
||||||
// check for changed buffer now, if this fails the argument list is not
|
// check for changed buffer now, if this fails the argument list is not
|
||||||
// redefined.
|
// redefined.
|
||||||
if (P_HID(curbuf)
|
if (buf_hide(curbuf)
|
||||||
|| eap->cmdidx == CMD_snext
|
|| eap->cmdidx == CMD_snext
|
||||||
|| !check_changed(curbuf, CCGD_AW
|
|| !check_changed(curbuf, CCGD_AW
|
||||||
| (eap->forceit ? CCGD_FORCEIT : 0)
|
| (eap->forceit ? CCGD_FORCEIT : 0)
|
||||||
@ -2008,7 +2008,7 @@ void ex_listdo(exarg_T *eap)
|
|||||||
|
|
||||||
if (eap->cmdidx == CMD_windo
|
if (eap->cmdidx == CMD_windo
|
||||||
|| eap->cmdidx == CMD_tabdo
|
|| eap->cmdidx == CMD_tabdo
|
||||||
|| P_HID(curbuf)
|
|| buf_hide(curbuf)
|
||||||
|| !check_changed(curbuf, CCGD_AW
|
|| !check_changed(curbuf, CCGD_AW
|
||||||
| (eap->forceit ? CCGD_FORCEIT : 0)
|
| (eap->forceit ? CCGD_FORCEIT : 0)
|
||||||
| CCGD_EXCMD)) {
|
| CCGD_EXCMD)) {
|
||||||
@ -3840,7 +3840,7 @@ void ex_drop(exarg_T *eap)
|
|||||||
// to split the current window or data could be lost.
|
// to split the current window or data could be lost.
|
||||||
// Skip the check if the 'hidden' option is set, as in this case the
|
// Skip the check if the 'hidden' option is set, as in this case the
|
||||||
// buffer won't be lost.
|
// buffer won't be lost.
|
||||||
if (!P_HID(curbuf)) {
|
if (!buf_hide(curbuf)) {
|
||||||
emsg_off++;
|
emsg_off++;
|
||||||
split = check_changed(curbuf, CCGD_AW | CCGD_EXCMD);
|
split = check_changed(curbuf, CCGD_AW | CCGD_EXCMD);
|
||||||
emsg_off--;
|
emsg_off--;
|
||||||
|
@ -5991,7 +5991,7 @@ static void ex_quit(exarg_T *eap)
|
|||||||
*/
|
*/
|
||||||
if (check_more(FALSE, eap->forceit) == OK && only_one_window())
|
if (check_more(FALSE, eap->forceit) == OK && only_one_window())
|
||||||
exiting = TRUE;
|
exiting = TRUE;
|
||||||
if ((!P_HID(curbuf)
|
if ((!buf_hide(curbuf)
|
||||||
&& check_changed(curbuf, (p_awa ? CCGD_AW : 0)
|
&& check_changed(curbuf, (p_awa ? CCGD_AW : 0)
|
||||||
| (eap->forceit ? CCGD_FORCEIT : 0)
|
| (eap->forceit ? CCGD_FORCEIT : 0)
|
||||||
| CCGD_EXCMD))
|
| CCGD_EXCMD))
|
||||||
@ -6009,7 +6009,7 @@ static void ex_quit(exarg_T *eap)
|
|||||||
getout(0);
|
getout(0);
|
||||||
}
|
}
|
||||||
/* close window; may free buffer */
|
/* close window; may free buffer */
|
||||||
win_close(wp, !P_HID(wp->w_buffer) || eap->forceit);
|
win_close(wp, !buf_hide(wp->w_buffer) || eap->forceit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6108,7 +6108,7 @@ ex_win_close (
|
|||||||
buf_T *buf = win->w_buffer;
|
buf_T *buf = win->w_buffer;
|
||||||
|
|
||||||
need_hide = (bufIsChanged(buf) && buf->b_nwindows <= 1);
|
need_hide = (bufIsChanged(buf) && buf->b_nwindows <= 1);
|
||||||
if (need_hide && !P_HID(buf) && !forceit) {
|
if (need_hide && !buf_hide(buf) && !forceit) {
|
||||||
if ((p_confirm || cmdmod.confirm) && p_write) {
|
if ((p_confirm || cmdmod.confirm) && p_write) {
|
||||||
bufref_T bufref;
|
bufref_T bufref;
|
||||||
set_bufref(&bufref, buf);
|
set_bufref(&bufref, buf);
|
||||||
@ -6126,9 +6126,9 @@ ex_win_close (
|
|||||||
|
|
||||||
/* free buffer when not hiding it or when it's a scratch buffer */
|
/* free buffer when not hiding it or when it's a scratch buffer */
|
||||||
if (tp == NULL)
|
if (tp == NULL)
|
||||||
win_close(win, !need_hide && !P_HID(buf));
|
win_close(win, !need_hide && !buf_hide(buf));
|
||||||
else
|
else
|
||||||
win_close_othertab(win, !need_hide && !P_HID(buf), tp);
|
win_close_othertab(win, !need_hide && !buf_hide(buf), tp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -6359,7 +6359,7 @@ static void ex_exit(exarg_T *eap)
|
|||||||
getout(0);
|
getout(0);
|
||||||
}
|
}
|
||||||
// Quit current window, may free the buffer.
|
// Quit current window, may free the buffer.
|
||||||
win_close(curwin, !P_HID(curwin->w_buffer));
|
win_close(curwin, !buf_hide(curwin->w_buffer));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6931,7 +6931,7 @@ do_exedit (
|
|||||||
if (do_ecmd(0, (eap->cmdidx == CMD_enew ? NULL : eap->arg),
|
if (do_ecmd(0, (eap->cmdidx == CMD_enew ? NULL : eap->arg),
|
||||||
NULL, eap,
|
NULL, eap,
|
||||||
eap->do_ecmd_lnum,
|
eap->do_ecmd_lnum,
|
||||||
(P_HID(curbuf) ? ECMD_HIDE : 0)
|
(buf_hide(curbuf) ? ECMD_HIDE : 0)
|
||||||
+ (eap->forceit ? ECMD_FORCEIT : 0)
|
+ (eap->forceit ? ECMD_FORCEIT : 0)
|
||||||
// After a split we can use an existing buffer.
|
// After a split we can use an existing buffer.
|
||||||
+ (old_curwin != NULL ? ECMD_OLDBUF : 0)
|
+ (old_curwin != NULL ? ECMD_OLDBUF : 0)
|
||||||
@ -6940,13 +6940,13 @@ do_exedit (
|
|||||||
/* Editing the file failed. If the window was split, close it. */
|
/* Editing the file failed. If the window was split, close it. */
|
||||||
if (old_curwin != NULL) {
|
if (old_curwin != NULL) {
|
||||||
need_hide = (curbufIsChanged() && curbuf->b_nwindows <= 1);
|
need_hide = (curbufIsChanged() && curbuf->b_nwindows <= 1);
|
||||||
if (!need_hide || P_HID(curbuf)) {
|
if (!need_hide || buf_hide(curbuf)) {
|
||||||
cleanup_T cs;
|
cleanup_T cs;
|
||||||
|
|
||||||
/* Reset the error/interrupt/exception state here so that
|
/* Reset the error/interrupt/exception state here so that
|
||||||
* aborting() returns FALSE when closing a window. */
|
* aborting() returns FALSE when closing a window. */
|
||||||
enter_cleanup(&cs);
|
enter_cleanup(&cs);
|
||||||
win_close(curwin, !need_hide && !P_HID(curbuf));
|
win_close(curwin, !need_hide && !buf_hide(curbuf));
|
||||||
|
|
||||||
/* Restore the error/interrupt/exception state if not
|
/* Restore the error/interrupt/exception state if not
|
||||||
* discarded by a new aborting error, interrupt, or
|
* discarded by a new aborting error, interrupt, or
|
||||||
|
@ -5230,12 +5230,12 @@ static void nv_gotofile(cmdarg_T *cap)
|
|||||||
|
|
||||||
if (ptr != NULL) {
|
if (ptr != NULL) {
|
||||||
// do autowrite if necessary
|
// do autowrite if necessary
|
||||||
if (curbufIsChanged() && curbuf->b_nwindows <= 1 && !P_HID(curbuf)) {
|
if (curbufIsChanged() && curbuf->b_nwindows <= 1 && !buf_hide(curbuf)) {
|
||||||
(void)autowrite(curbuf, false);
|
(void)autowrite(curbuf, false);
|
||||||
}
|
}
|
||||||
setpcmark();
|
setpcmark();
|
||||||
(void)do_ecmd(0, ptr, NULL, NULL, ECMD_LAST,
|
(void)do_ecmd(0, ptr, NULL, NULL, ECMD_LAST,
|
||||||
P_HID(curbuf) ? ECMD_HIDE : 0, curwin);
|
buf_hide(curbuf) ? ECMD_HIDE : 0, curwin);
|
||||||
if (cap->nchar == 'F' && lnum >= 0) {
|
if (cap->nchar == 'F' && lnum >= 0) {
|
||||||
curwin->w_cursor.lnum = lnum;
|
curwin->w_cursor.lnum = lnum;
|
||||||
check_cursor_lnum();
|
check_cursor_lnum();
|
||||||
|
@ -454,9 +454,6 @@ EXTERN char_u *p_hf; // 'helpfile'
|
|||||||
EXTERN long p_hh; // 'helpheight'
|
EXTERN long p_hh; // 'helpheight'
|
||||||
EXTERN char_u *p_hlg; // 'helplang'
|
EXTERN char_u *p_hlg; // 'helplang'
|
||||||
EXTERN int p_hid; // 'hidden'
|
EXTERN int p_hid; // 'hidden'
|
||||||
// Use P_HID to check if a buffer is to be hidden when it is no longer
|
|
||||||
// visible in a window.
|
|
||||||
# define P_HID(buf) (buf_hide(buf))
|
|
||||||
EXTERN char_u *p_hl; // 'highlight'
|
EXTERN char_u *p_hl; // 'highlight'
|
||||||
EXTERN int p_hls; // 'hlsearch'
|
EXTERN int p_hls; // 'hlsearch'
|
||||||
EXTERN long p_hi; // 'history'
|
EXTERN long p_hi; // 'history'
|
||||||
|
@ -2857,7 +2857,7 @@ close_others (
|
|||||||
if (bufIsChanged(wp->w_buffer))
|
if (bufIsChanged(wp->w_buffer))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
win_close(wp, !P_HID(wp->w_buffer) && !bufIsChanged(wp->w_buffer));
|
win_close(wp, !buf_hide(wp->w_buffer) && !bufIsChanged(wp->w_buffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message && !ONE_WINDOW)
|
if (message && !ONE_WINDOW)
|
||||||
|
Loading…
Reference in New Issue
Block a user