diff src/terminal.c @ 30747:58592b6af4e2 v9.0.0708

patch 9.0.0708: :confirm does not work properly for a terminal buffer Commit: https://github.com/vim/vim/commit/15b314ffbb93f934b72cb71aa8f881caea026256 Author: Yee Cheng Chin <ychin.git@gmail.com> Date: Sun Oct 9 18:53:32 2022 +0100 patch 9.0.0708: :confirm does not work properly for a terminal buffer Problem: :confirm does not work properly for a terminal buffer. Solution: Handle :confirm for a terminal buffer differently. (Yee Cheng Chin, closes #11312)
author Bram Moolenaar <Bram@vim.org>
date Sun, 09 Oct 2022 20:00:04 +0200
parents 101f08b49ed3
children c7983f593fa7
line wrap: on
line diff
--- 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