summaryrefslogtreecommitdiff
path: root/src/buffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c81
1 files changed, 61 insertions, 20 deletions
diff --git a/src/buffer.c b/src/buffer.c
index f74348d69..97b41e0a8 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -49,6 +49,7 @@ static int append_arg_number(win_T *wp, char_u *buf, int buflen, int add_file);
static void free_buffer(buf_T *);
static void free_buffer_stuff(buf_T *buf, int free_options);
static int bt_nofileread(buf_T *buf);
+static void no_write_message_buf(buf_T *buf);
#ifdef UNIX
# define dev_T dev_t
@@ -1367,21 +1368,30 @@ do_buffer_ext(
#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
if ((p_confirm || (cmdmod.cmod_flags & CMOD_CONFIRM)) && p_write)
{
- dialog_changed(buf, FALSE);
- if (!bufref_valid(&bufref))
- // Autocommand deleted buffer, oops! It's not changed
- // now.
- return FAIL;
- // If it's still changed fail silently, the dialog already
- // mentioned why it fails.
- if (bufIsChanged(buf))
- return FAIL;
+# ifdef FEAT_TERMINAL
+ if (term_job_running(buf->b_term))
+ {
+ if (term_confirm_stop(buf) == FAIL)
+ return FAIL;
+ }
+ else
+# endif
+ {
+ dialog_changed(buf, FALSE);
+ if (!bufref_valid(&bufref))
+ // Autocommand deleted buffer, oops! It's not changed
+ // now.
+ return FAIL;
+ // If it's still changed fail silently, the dialog already
+ // mentioned why it fails.
+ if (bufIsChanged(buf))
+ return FAIL;
+ }
}
else
#endif
{
- semsg(_(e_no_write_since_last_change_for_buffer_nr_add_bang_to_override),
- buf->b_fnum);
+ no_write_message_buf(buf);
return FAIL;
}
}
@@ -1552,15 +1562,34 @@ do_buffer_ext(
#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
if ((p_confirm || (cmdmod.cmod_flags & CMOD_CONFIRM)) && p_write)
{
- bufref_T bufref;
+# ifdef FEAT_TERMINAL
+ if (term_job_running(curbuf->b_term))
+ {
+ if (term_confirm_stop(curbuf) == FAIL)
+ return FAIL;
+ // Manually kill the terminal here because this command will
+ // hide it otherwise.
+ free_terminal(curbuf);
+ }
+ else
+# endif
+ {
+ bufref_T bufref;
- set_bufref(&bufref, buf);
- dialog_changed(curbuf, FALSE);
- if (!bufref_valid(&bufref))
- // Autocommand deleted buffer, oops!
- return FAIL;
+ set_bufref(&bufref, buf);
+ dialog_changed(curbuf, FALSE);
+ if (!bufref_valid(&bufref))
+ // Autocommand deleted buffer, oops!
+ return FAIL;
+
+ if (bufIsChanged(curbuf))
+ {
+ no_write_message();
+ return FAIL;
+ }
+ }
}
- if (bufIsChanged(curbuf))
+ else
#endif
{
no_write_message();
@@ -1940,6 +1969,18 @@ do_autochdir(void)
}
#endif
+ static void
+no_write_message_buf(buf_T *buf UNUSED)
+{
+#ifdef FEAT_TERMINAL
+ if (term_job_running(buf->b_term))
+ emsg(_(e_job_still_running_add_bang_to_end_the_job));
+ else
+#endif
+ semsg(_(e_no_write_since_last_change_for_buffer_nr_add_bang_to_override),
+ buf->b_fnum);
+}
+
void
no_write_message(void)
{
@@ -5751,8 +5792,8 @@ bt_nofile(buf_T *buf)
#endif
/*
- * Return TRUE if "buf" is a "nowrite", "nofile", "terminal" or "prompt"
- * buffer.
+ * Return TRUE if "buf" is a "nowrite", "nofile", "terminal", "prompt", or
+ * "popup" buffer.
*/
int
bt_dontwrite(buf_T *buf)