diff options
author | Bram Moolenaar <Bram@vim.org> | 2017-08-12 14:52:15 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2017-08-12 14:52:15 +0200 |
commit | 9698ad7201ca1a3acec69679f1ab8b15323ff406 (patch) | |
tree | 2152ad953198c606407f3c600f2ade1b3467a3bf /src | |
parent | 8cad930a259a05a95c7d0c527a5881d5f9a59057 (diff) | |
download | vim-git-9698ad7201ca1a3acec69679f1ab8b15323ff406.tar.gz |
patch 8.0.0913: MS-Windows: CTRL-C kills shell in terminal windowv8.0.0913
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)
Diffstat (limited to 'src')
-rw-r--r-- | src/globals.h | 4 | ||||
-rw-r--r-- | src/gui_w32.c | 1 | ||||
-rw-r--r-- | src/os_win32.c | 1 | ||||
-rw-r--r-- | src/terminal.c | 14 | ||||
-rw-r--r-- | src/version.c | 2 |
5 files changed, 18 insertions, 4 deletions
diff --git a/src/globals.h b/src/globals.h index d0938fda6..d42056098 100644 --- a/src/globals.h +++ b/src/globals.h @@ -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. */ diff --git a/src/gui_w32.c b/src/gui_w32.c index a91e0710b..863975c7f 100644 --- a/src/gui_w32.c +++ b/src/gui_w32.c @@ -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); } diff --git a/src/os_win32.c b/src/os_win32.c index add83d344..496f95f72 100644 --- a/src/os_win32.c +++ b/src/os_win32.c @@ -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; } diff --git a/src/terminal.c b/src/terminal.c index 18fed65f0..63e1cec5f 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -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) diff --git a/src/version.c b/src/version.c index 2d16a644c..314b62dbf 100644 --- a/src/version.c +++ b/src/version.c @@ -770,6 +770,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 913, +/**/ 912, /**/ 911, |