]> granicus.if.org Git - vim/commitdiff
patch 8.0.0913: MS-Windows: CTRL-C kills shell in terminal window v8.0.0913
authorBram Moolenaar <Bram@vim.org>
Sat, 12 Aug 2017 12:52:15 +0000 (14:52 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 12 Aug 2017 12:52:15 +0000 (14:52 +0200)
Problem:    MS-Windows: CTRL-C kills shell in terminal window instead of the
            command running in the shell.
Solution:   Make CTRL-C only send a CTRL_C_EVENT and have CTRL-BREAK kill the
            job. (partly by Yasuhiro Matsumoto, closes #1962)

src/globals.h
src/gui_w32.c
src/os_win32.c
src/terminal.c
src/version.c

index d0938fda64c878a169f321b122cb3a40ac6197b9..d420560988e9378263ea7f9ce3c69496d9e0a3c8 100644 (file)
@@ -1671,6 +1671,10 @@ EXTERN int  did_echo_string_emsg INIT(= FALSE);
 EXTERN int *eval_lavars_used INIT(= NULL);
 #endif
 
+#ifdef WIN3264
+EXTERN int ctrl_break_was_pressed = FALSE;
+#endif
+
 /*
  * Optional Farsi support.  Include it here, so EXTERN and INIT are defined.
  */
index a91e0710beb38fc1e780b906f6159e3a16942264..863975c7f451a9f46c07b79ea4a9e77d5f38cf24 100644 (file)
@@ -1840,6 +1840,7 @@ process_message(void)
        {
            trash_input_buf();
            got_int = TRUE;
+           ctrl_break_was_pressed = TRUE;
            string[0] = Ctrl_C;
            add_to_input_buf(string, 1);
        }
index add83d34445cd404fef34a5a20b7e57a36e278f1..496f95f72018bed12f4866da5c526e25582e41ae 100644 (file)
@@ -6296,6 +6296,7 @@ mch_breakcheck(int force)
 #ifndef FEAT_GUI_W32       /* never used */
     if (g_fCtrlCPressed || g_fCBrkPressed)
     {
+       ctrl_break_was_pressed = g_fCBrkPressed;
        g_fCtrlCPressed = g_fCBrkPressed = FALSE;
        got_int = TRUE;
     }
index 18fed65f0384b5d657e4382ade43c8744f6b3435..63e1cec5f571b6deccba57315335cc17241c3de8 100644 (file)
@@ -1016,6 +1016,9 @@ term_vgetc()
     ++no_mapping;
     ++allow_keys;
     got_int = FALSE;
+#ifdef WIN3264
+    ctrl_break_was_pressed = FALSE;
+#endif
     c = vgetc();
     got_int = FALSE;
     --no_mapping;
@@ -1201,11 +1204,14 @@ terminal_loop(void)
        may_send_sigint(c, curbuf->b_term->tl_job->jv_pid, 0);
 #endif
 #ifdef WIN3264
+       /* On Windows we do not know whether the job can handle CTRL-C itself
+        * or not.  Therefore CTRL-C only sends a CTRL_C_EVENT to avoid killing
+        * the shell instead of a command running in the shell.
+        * Use CTRL-BREAK to kill the job. */
        if (c == Ctrl_C)
-           /* We don't know if the job can handle CTRL-C itself or not, this
-            * may kill the shell instead of killing the command running in the
-            * shell. */
-           mch_signal_job(curbuf->b_term->tl_job, (char_u *)"quit");
+           mch_signal_job(curbuf->b_term->tl_job, (char_u *)"int");
+       if (ctrl_break_was_pressed)
+           mch_signal_job(curbuf->b_term->tl_job, (char_u *)"kill");
 #endif
 
        if (c == (termkey == 0 ? Ctrl_W : termkey) || c == Ctrl_BSL)
index 2d16a644c25e7425942b762b3f6df3d93be0c0e4..314b62dbfe9c5dc9d3c4598b10bdddf72fdd993c 100644 (file)
@@ -769,6 +769,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    913,
 /**/
     912,
 /**/