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);
|
||||
close_buffer(prevbuf == curwin->w_buffer ? curwin : NULL, prevbuf,
|
||||
unload ? action : (action == DOBUF_GOTO
|
||||
&& !P_HID(prevbuf)
|
||||
&& !buf_hide(prevbuf)
|
||||
&& !bufIsChanged(
|
||||
prevbuf)) ? DOBUF_UNLOAD : 0, FALSE);
|
||||
if (curwin != previouswin && win_valid(previouswin))
|
||||
@ -4414,11 +4414,11 @@ do_arg_all (
|
||||
wp->w_arg_idx = i;
|
||||
|
||||
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)) {
|
||||
/* If the buffer was changed, and we would like to hide it,
|
||||
* 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;
|
||||
set_bufref(&bufref, buf);
|
||||
(void)autowrite(buf, false);
|
||||
@ -4433,7 +4433,7 @@ do_arg_all (
|
||||
&& (first_tabpage->tp_next == NULL || !had_tab)) {
|
||||
use_firstwin = true;
|
||||
} else {
|
||||
win_close(wp, !P_HID(buf) && !bufIsChanged(buf));
|
||||
win_close(wp, !buf_hide(buf) && !bufIsChanged(buf));
|
||||
// check if autocommands removed the next window
|
||||
if (!win_valid(wpnext)) {
|
||||
// start all over...
|
||||
@ -4513,7 +4513,7 @@ do_arg_all (
|
||||
}
|
||||
(void)do_ecmd(0, alist_name(&AARGLIST(alist)[i]), NULL, NULL,
|
||||
ECMD_ONE,
|
||||
((P_HID(curwin->w_buffer)
|
||||
((buf_hide(curwin->w_buffer)
|
||||
|| bufIsChanged(curwin->w_buffer)) ? ECMD_HIDE : 0)
|
||||
+ ECMD_OLDBUF, curwin);
|
||||
if (use_firstwin)
|
||||
@ -4705,13 +4705,13 @@ void ex_buffer_all(exarg_T *eap)
|
||||
* Close superfluous windows.
|
||||
*/
|
||||
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);
|
||||
if (!win_valid(wp)) {
|
||||
/* BufWrite Autocommands made the window invalid, start over */
|
||||
wp = lastwin;
|
||||
} else if (r) {
|
||||
win_close(wp, !P_HID(wp->w_buffer));
|
||||
win_close(wp, !buf_hide(wp->w_buffer));
|
||||
--open_wins;
|
||||
wp = lastwin;
|
||||
} else {
|
||||
|
@ -2015,7 +2015,7 @@ int getfile(int fnum, char_u *ffname, char_u *sfname, int setpm, linenr_T lnum,
|
||||
|
||||
if (other)
|
||||
++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) {
|
||||
if (p_confirm && p_write)
|
||||
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);
|
||||
retval = 0; /* it's in the same file */
|
||||
} 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)
|
||||
retval = -1; /* opened another file */
|
||||
else
|
||||
|
@ -1343,7 +1343,7 @@ void dialog_changed(buf_T *buf, int checkall)
|
||||
/// hidden, autowriting it or unloading it.
|
||||
bool can_abandon(buf_T *buf, int forceit)
|
||||
{
|
||||
return P_HID(buf)
|
||||
return buf_hide(buf)
|
||||
|| !bufIsChanged(buf)
|
||||
|| buf->b_nwindows > 1
|
||||
|| 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
|
||||
// the same buffer
|
||||
other = true;
|
||||
if (P_HID(curbuf)) {
|
||||
if (buf_hide(curbuf)) {
|
||||
p = (char_u *)fix_fname((char *)alist_name(&ARGLIST[argn]));
|
||||
other = otherfile(p);
|
||||
xfree(p);
|
||||
}
|
||||
if ((!P_HID(curbuf) || !other)
|
||||
if ((!buf_hide(curbuf) || !other)
|
||||
&& check_changed(curbuf, CCGD_AW
|
||||
| (other ? 0 : CCGD_MULTWIN)
|
||||
| (eap->forceit ? CCGD_FORCEIT : 0)
|
||||
@ -1885,7 +1885,7 @@ void do_argfile(exarg_T *eap, int argn)
|
||||
// argument index.
|
||||
if (do_ecmd(0, alist_name(&ARGLIST[curwin->w_arg_idx]), NULL,
|
||||
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) {
|
||||
curwin->w_arg_idx = old_arg_idx;
|
||||
} 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
|
||||
// redefined.
|
||||
if (P_HID(curbuf)
|
||||
if (buf_hide(curbuf)
|
||||
|| eap->cmdidx == CMD_snext
|
||||
|| !check_changed(curbuf, CCGD_AW
|
||||
| (eap->forceit ? CCGD_FORCEIT : 0)
|
||||
@ -2008,7 +2008,7 @@ void ex_listdo(exarg_T *eap)
|
||||
|
||||
if (eap->cmdidx == CMD_windo
|
||||
|| eap->cmdidx == CMD_tabdo
|
||||
|| P_HID(curbuf)
|
||||
|| buf_hide(curbuf)
|
||||
|| !check_changed(curbuf, CCGD_AW
|
||||
| (eap->forceit ? CCGD_FORCEIT : 0)
|
||||
| CCGD_EXCMD)) {
|
||||
@ -3840,7 +3840,7 @@ void ex_drop(exarg_T *eap)
|
||||
// to split the current window or data could be lost.
|
||||
// Skip the check if the 'hidden' option is set, as in this case the
|
||||
// buffer won't be lost.
|
||||
if (!P_HID(curbuf)) {
|
||||
if (!buf_hide(curbuf)) {
|
||||
emsg_off++;
|
||||
split = check_changed(curbuf, CCGD_AW | CCGD_EXCMD);
|
||||
emsg_off--;
|
||||
|
@ -5991,7 +5991,7 @@ static void ex_quit(exarg_T *eap)
|
||||
*/
|
||||
if (check_more(FALSE, eap->forceit) == OK && only_one_window())
|
||||
exiting = TRUE;
|
||||
if ((!P_HID(curbuf)
|
||||
if ((!buf_hide(curbuf)
|
||||
&& check_changed(curbuf, (p_awa ? CCGD_AW : 0)
|
||||
| (eap->forceit ? CCGD_FORCEIT : 0)
|
||||
| CCGD_EXCMD))
|
||||
@ -6009,7 +6009,7 @@ static void ex_quit(exarg_T *eap)
|
||||
getout(0);
|
||||
}
|
||||
/* 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;
|
||||
|
||||
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) {
|
||||
bufref_T bufref;
|
||||
set_bufref(&bufref, buf);
|
||||
@ -6126,9 +6126,9 @@ ex_win_close (
|
||||
|
||||
/* free buffer when not hiding it or when it's a scratch buffer */
|
||||
if (tp == NULL)
|
||||
win_close(win, !need_hide && !P_HID(buf));
|
||||
win_close(win, !need_hide && !buf_hide(buf));
|
||||
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);
|
||||
}
|
||||
// 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),
|
||||
NULL, eap,
|
||||
eap->do_ecmd_lnum,
|
||||
(P_HID(curbuf) ? ECMD_HIDE : 0)
|
||||
(buf_hide(curbuf) ? ECMD_HIDE : 0)
|
||||
+ (eap->forceit ? ECMD_FORCEIT : 0)
|
||||
// After a split we can use an existing buffer.
|
||||
+ (old_curwin != NULL ? ECMD_OLDBUF : 0)
|
||||
@ -6940,13 +6940,13 @@ do_exedit (
|
||||
/* Editing the file failed. If the window was split, close it. */
|
||||
if (old_curwin != NULL) {
|
||||
need_hide = (curbufIsChanged() && curbuf->b_nwindows <= 1);
|
||||
if (!need_hide || P_HID(curbuf)) {
|
||||
if (!need_hide || buf_hide(curbuf)) {
|
||||
cleanup_T cs;
|
||||
|
||||
/* Reset the error/interrupt/exception state here so that
|
||||
* aborting() returns FALSE when closing a window. */
|
||||
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
|
||||
* discarded by a new aborting error, interrupt, or
|
||||
|
@ -5230,12 +5230,12 @@ static void nv_gotofile(cmdarg_T *cap)
|
||||
|
||||
if (ptr != NULL) {
|
||||
// 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);
|
||||
}
|
||||
setpcmark();
|
||||
(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) {
|
||||
curwin->w_cursor.lnum = lnum;
|
||||
check_cursor_lnum();
|
||||
|
@ -454,9 +454,6 @@ EXTERN char_u *p_hf; // 'helpfile'
|
||||
EXTERN long p_hh; // 'helpheight'
|
||||
EXTERN char_u *p_hlg; // 'helplang'
|
||||
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 int p_hls; // 'hlsearch'
|
||||
EXTERN long p_hi; // 'history'
|
||||
|
@ -2857,7 +2857,7 @@ close_others (
|
||||
if (bufIsChanged(wp->w_buffer))
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user