terminal: handle &confirm and :confirm on unloading (#8726)

Show a proper confirmation dialog when trying to unload a terminal buffer while
the confirm option is set or when :confirm is used.

Fixes https://github.com/neovim/neovim/issues/4651
This commit is contained in:
Marco Hinz
2018-07-12 14:57:20 +02:00
committed by GitHub
parent 56065bbdc6
commit 01570f1ff3
3 changed files with 48 additions and 3 deletions

View File

@@ -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;
}
}