0
0
mirror of https://github.com/vim/vim.git synced 2025-09-29 04:34:16 -04:00

patch 8.0.0953: get "no write since last change" error in terminal window

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.
This commit is contained in:
Bram Moolenaar
2017-08-17 16:55:13 +02:00
parent a83e3962ac
commit f5be7cd016
9 changed files with 35 additions and 11 deletions

View File

@@ -473,8 +473,8 @@ close_buffer(
{ {
if (term_job_running(buf->b_term)) if (term_job_running(buf->b_term))
{ {
if (wipe_buf) if (wipe_buf || unload_buf)
/* Wiping out a terminal buffer kills the job. */ /* Wiping out or unloading a terminal buffer kills the job. */
free_terminal(buf); free_terminal(buf);
else else
{ {
@@ -1648,7 +1648,7 @@ do_buffer(
if (bufIsChanged(curbuf)) if (bufIsChanged(curbuf))
#endif #endif
{ {
EMSG(_(e_nowrtmsg)); no_write_message();
return FAIL; return FAIL;
} }
} }
@@ -1897,6 +1897,28 @@ do_autochdir(void)
} }
#endif #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 * functions for dealing with the buffer list
*/ */

View File

@@ -3572,7 +3572,7 @@ getfile(
{ {
if (other) if (other)
--no_wait_return; --no_wait_return;
EMSG(_(e_nowrtmsg)); no_write_message();
retval = GETFILE_NOT_WRITTEN; /* file has been changed */ retval = GETFILE_NOT_WRITTEN; /* file has been changed */
goto theend; goto theend;
} }

View File

@@ -1934,9 +1934,9 @@ check_changed(buf_T *buf, int flags)
} }
#endif #endif
if (flags & CCGD_EXCMD) if (flags & CCGD_EXCMD)
EMSG(_(e_nowrtmsg)); no_write_message();
else else
EMSG(_(e_nowrtmsg_nobang)); no_write_message_nobang();
return TRUE; return TRUE;
} }
return FALSE; return FALSE;

View File

@@ -7468,7 +7468,7 @@ ex_win_close(
else else
# endif # endif
{ {
EMSG(_(e_nowrtmsg)); no_write_message();
return; return;
} }
} }

View 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_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_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_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")); EXTERN char_u e_null[] INIT(= N_("E38: Null argument"));
#if defined(FEAT_DIGRAPHS) || defined(FEAT_TIMERS) #if defined(FEAT_DIGRAPHS) || defined(FEAT_TIMERS)
EXTERN char_u e_number_exp[] INIT(= N_("E39: Number expected")); EXTERN char_u e_number_exp[] INIT(= N_("E39: Number expected"));

View 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 set_curbuf(buf_T *buf, int action);
void enter_buffer(buf_T *buf); void enter_buffer(buf_T *buf);
void do_autochdir(void); 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); 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); void free_buf_options(buf_T *buf, int free_p_ff);
int buflist_getfile(int n, linenr_T lnum, int options, int forceit); int buflist_getfile(int n, linenr_T lnum, int options, int forceit);

View File

@@ -2327,7 +2327,7 @@ win_found:
* set b_p_ro flag). */ * set b_p_ro flag). */
if (!can_abandon(curbuf, forceit)) if (!can_abandon(curbuf, forceit))
{ {
EMSG(_(e_nowrtmsg)); no_write_message();
ok = FALSE; ok = FALSE;
} }
else else

View File

@@ -267,7 +267,7 @@ term_start(typval_T *argvar, jobopt_T *opt, int forceit)
/* Create a new buffer in the current window. */ /* Create a new buffer in the current window. */
if (!can_abandon(curbuf, forceit)) if (!can_abandon(curbuf, forceit))
{ {
EMSG(_(e_nowrtmsg)); no_write_message();
vim_free(term); vim_free(term);
return; return;
} }

View File

@@ -769,6 +769,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
953,
/**/ /**/
952, 952,
/**/ /**/