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.
diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c
index 381c5d1..26b588c 100644
--- a/src/ex_cmds2.c
+++ b/src/ex_cmds2.c
@@ -2064,7 +2064,7 @@
int
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
@@ -2180,7 +2180,14 @@
msg_col = 0;
msg_didout = FALSE;
}
- if (EMSG2(_("E162: No write since last change for buffer \"%s\""),
+ if (
+#ifdef FEAT_TERMINAL
+ term_job_running(buf->b_term)
+ ? EMSG2(_("E947: Job still running in buffer \"%s\""),
+ buf->b_fname)
+ :
+#endif
+ EMSG2(_("E162: No write since last change for buffer \"%s\""),
buf_spname(buf) != NULL ? buf_spname(buf) : buf->b_fname))
{
save = no_wait_return;
@@ -2734,13 +2741,13 @@
* the same buffer
*/
other = TRUE;
- if (P_HID(curbuf))
+ if (buf_hide(curbuf))
{
p = fix_fname(alist_name(&ARGLIST[argn]));
other = otherfile(p);
vim_free(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)
@@ -2761,7 +2768,7 @@
* 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;
/* like Vi: set the mark where the cursor is in the file. */
@@ -2782,7 +2789,7 @@
* 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)
@@ -2937,7 +2944,7 @@
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))