]> granicus.if.org Git - vim/commitdiff
patch 8.0.0953: get "no write since last change" error in terminal window v8.0.0953
authorBram Moolenaar <Bram@vim.org>
Thu, 17 Aug 2017 14:55:13 +0000 (16:55 +0200)
committerBram Moolenaar <Bram@vim.org>
Thu, 17 Aug 2017 14:55:13 +0000 (16:55 +0200)
Problem:    Get "no write since last change" error in terminal window.
Solution:   Use another message when closing a terminal window. Make ":quit!"
            also end the job.

src/buffer.c
src/ex_cmds.c
src/ex_cmds2.c
src/ex_docmd.c
src/globals.h
src/proto/buffer.pro
src/quickfix.c
src/terminal.c
src/version.c

index 3934941565fdb1d894597bfa401e5dcfc2acd2d4..f64255d7856d1fc512630ff74c2d71e548594673 100644 (file)
@@ -473,8 +473,8 @@ close_buffer(
     {
        if (term_job_running(buf->b_term))
        {
-           if (wipe_buf)
-               /* Wiping out a terminal buffer kills the job. */
+           if (wipe_buf || unload_buf)
+               /* Wiping out or unloading a terminal buffer kills the job. */
                free_terminal(buf);
            else
            {
@@ -1648,7 +1648,7 @@ do_buffer(
        if (bufIsChanged(curbuf))
 #endif
        {
-           EMSG(_(e_nowrtmsg));
+           no_write_message();
            return FAIL;
        }
     }
@@ -1897,6 +1897,28 @@ do_autochdir(void)
 }
 #endif
 
+    void
+no_write_message(void)
+{
+#ifdef FEAT_TERMINAL
+    if (term_job_running(curbuf->b_term))
+       EMSG(_("E948: Job still running (add ! to end the job)"));
+    else
+#endif
+       EMSG(_("E37: No write since last change (add ! to override)"));
+}
+
+    void
+no_write_message_nobang(void)
+{
+#ifdef FEAT_TERMINAL
+    if (term_job_running(curbuf->b_term))
+       EMSG(_("E948: Job still running"));
+    else
+#endif
+       EMSG(_("E37: No write since last change"));
+}
+
 /*
  * functions for dealing with the buffer list
  */
index 61c85a917f3bbd296520895c58aefb04e63d338d..8b21b81f2a66b5b6b4a57524589d6dd9741d199a 100644 (file)
@@ -3572,7 +3572,7 @@ getfile(
        {
            if (other)
                --no_wait_return;
-           EMSG(_(e_nowrtmsg));
+           no_write_message();
            retval = GETFILE_NOT_WRITTEN;       /* file has been changed */
            goto theend;
        }
index 8a11fbbe9f7e06c8568b2fd7b060d931fc110ab1..8ca11f0663d45d2eefa46a53464d5a145be0ccb3 100644 (file)
@@ -1934,9 +1934,9 @@ check_changed(buf_T *buf, int flags)
        }
 #endif
        if (flags & CCGD_EXCMD)
-           EMSG(_(e_nowrtmsg));
+           no_write_message();
        else
-           EMSG(_(e_nowrtmsg_nobang));
+           no_write_message_nobang();
        return TRUE;
     }
     return FALSE;
index fa5a888d4ee111638e88818f77b8a6a14e993c21..70f3e573d958a7df683628f0de6948ce8ca0b9ee 100644 (file)
@@ -7468,7 +7468,7 @@ ex_win_close(
        else
 # endif
        {
-           EMSG(_(e_nowrtmsg));
+           no_write_message();
            return;
        }
     }
index 7f2875b05e62bd4fbde56be41c3005bdc52aab22..0b887d35bb6e2ab5e3d48253fc9c886ba70c7197 100644 (file)
@@ -1516,8 +1516,6 @@ EXTERN char_u e_notcreate[]       INIT(= N_("E482: Can't create file %s"));
 EXTERN char_u e_notmp[]                INIT(= N_("E483: Can't get temp file name"));
 EXTERN char_u e_notopen[]      INIT(= N_("E484: Can't open file %s"));
 EXTERN char_u e_notread[]      INIT(= N_("E485: Can't read file %s"));
-EXTERN char_u e_nowrtmsg[]     INIT(= N_("E37: No write since last change (add ! to override)"));
-EXTERN char_u e_nowrtmsg_nobang[]   INIT(= N_("E37: No write since last change"));
 EXTERN char_u e_null[]         INIT(= N_("E38: Null argument"));
 #if defined(FEAT_DIGRAPHS) || defined(FEAT_TIMERS)
 EXTERN char_u e_number_exp[]   INIT(= N_("E39: Number expected"));
index d70981dac0b2429a7c75619d213d766e06eed599..485eb027de95d119bd1fa2c3d8e8d48e3741065f 100644 (file)
@@ -13,6 +13,8 @@ int do_buffer(int action, int start, int dir, int count, int forceit);
 void set_curbuf(buf_T *buf, int action);
 void enter_buffer(buf_T *buf);
 void do_autochdir(void);
+void no_write_message(void);
+void no_write_message_nobang(void);
 buf_T *buflist_new(char_u *ffname, char_u *sfname, linenr_T lnum, int flags);
 void free_buf_options(buf_T *buf, int free_p_ff);
 int buflist_getfile(int n, linenr_T lnum, int options, int forceit);
index 8c55a16c7f59eb1f2c0b6e077af51f9b70e792ae..42077c2a3c8544effb43d03467305a9c22496d21 100644 (file)
@@ -2327,7 +2327,7 @@ win_found:
             * set b_p_ro flag). */
            if (!can_abandon(curbuf, forceit))
            {
-               EMSG(_(e_nowrtmsg));
+               no_write_message();
                ok = FALSE;
            }
            else
index d482d19525fa99525eef230f98ce8f0dc14daecc..304a7ba43bc2999536e948379c1831a1e712c0ca 100644 (file)
@@ -267,7 +267,7 @@ term_start(typval_T *argvar, jobopt_T *opt, int forceit)
        /* Create a new buffer in the current window. */
        if (!can_abandon(curbuf, forceit))
        {
-           EMSG(_(e_nowrtmsg));
+           no_write_message();
            vim_free(term);
            return;
        }
index 545204cf16b64b2d3263a9195f71a549777392b4..352e0a9fef9adeb307901f1be70f7ac3eea26c2b 100644 (file)
@@ -769,6 +769,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    953,
 /**/
     952,
 /**/