diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/buffer.c | 13 | ||||
-rw-r--r-- | src/nvim/ex_cmds2.c | 16 |
2 files changed, 26 insertions, 3 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 95eaf4dcf6..81bbc56eb9 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -1172,14 +1172,21 @@ do_buffer ( } } else { if (buf->terminal) { - EMSG2(_("E89: %s will be killed(add ! to override)"), - (char *)buf->b_fname); + if (p_confirm || cmdmod.confirm) { + if (!dialog_close_terminal(buf)) { + return FAIL; + } + } else { + EMSG2(_("E89: %s will be killed(add ! to override)"), + (char *)buf->b_fname); + return FAIL; + } } else { EMSGN(_("E89: No write since last change for buffer %" PRId64 " (add ! to override)"), buf->b_fnum); + return FAIL; } - return FAIL; } } diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 46a7c869e1..f07bc0e137 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -1339,6 +1339,22 @@ void dialog_changed(buf_T *buf, int checkall) } } +/// Ask the user whether to close the terminal buffer or not. +/// +/// @param buf The terminal buffer. +/// @return bool Whether to close the buffer or not. +bool dialog_close_terminal(buf_T *buf) +{ + char_u buff[DIALOG_MSG_SIZE]; + + dialog_msg(buff, _("Close \"%s\"?"), + (buf->b_fname != NULL) ? buf->b_fname : (char_u *)"?"); + + int ret = vim_dialog_yesnocancel(VIM_QUESTION, NULL, buff, 1); + + return (ret == VIM_YES) ? true : false; +} + /// Return true if the buffer "buf" can be abandoned, either by making it /// hidden, autowriting it or unloading it. bool can_abandon(buf_T *buf, int forceit) |