diff options
author | Yee Cheng Chin <ychin.git@gmail.com> | 2022-10-09 18:53:32 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-10-09 18:53:32 +0100 |
commit | 15b314ffbb93f934b72cb71aa8f881caea026256 (patch) | |
tree | cffce54dd07078c4d6407e7e06a2823f945e6ef6 /src/terminal.c | |
parent | 118c235112854f34182d968613d7fe98be3b290b (diff) |
patch 9.0.0708: :confirm does not work properly for a terminal bufferv9.0.0708
Problem: :confirm does not work properly for a terminal buffer.
Solution: Handle :confirm for a terminal buffer differently. (Yee Cheng
Chin, closes #11312)
Diffstat (limited to 'src/terminal.c')
-rw-r--r-- | src/terminal.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/src/terminal.c b/src/terminal.c index f5687df612..46ed325a52 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -1651,6 +1651,25 @@ term_none_open(term_T *term) && term->tl_job->jv_channel->ch_keep_open; } +// +// Used to confirm whether we would like to kill a terminal. +// Return OK when the user confirms to kill it. +// Return FAIL if the user selects otherwise. +// + int +term_confirm_stop(buf_T *buf) +{ + char_u buff[DIALOG_MSG_SIZE]; + int ret; + + dialog_msg(buff, _("Kill job in \"%s\"?"), buf_get_fname(buf)); + ret = vim_dialog_yesno(VIM_QUESTION, NULL, buff, 1); + if (ret == VIM_YES) + return OK; + else + return FAIL; +} + /* * Used when exiting: kill the job in "buf" if so desired. * Return OK when the job finished. @@ -1666,14 +1685,9 @@ term_try_stop_job(buf_T *buf) if ((how == NULL || *how == NUL) && (p_confirm || (cmdmod.cmod_flags & CMOD_CONFIRM))) { - char_u buff[DIALOG_MSG_SIZE]; - int ret; - - dialog_msg(buff, _("Kill job in \"%s\"?"), buf_get_fname(buf)); - ret = vim_dialog_yesnocancel(VIM_QUESTION, NULL, buff, 1); - if (ret == VIM_YES) + if (term_confirm_stop(buf) == OK) how = "kill"; - else if (ret == VIM_CANCEL) + else return FAIL; } #endif |