Skip to content

Commit 8e539c5

Browse files
committed
patch 8.0.0960: job in terminal does not get CTRL-C
Problem: Job in terminal does not get CTRL-C, we send a SIGINT instead. Solution: Don't call may_send_sigint() on CTRL-C. Make CTRL-W CTRL-C end the job.
1 parent f66a2cd commit 8e539c5

3 files changed

Lines changed: 31 additions & 8 deletions

File tree

runtime/doc/terminal.txt

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ Special in the terminal window: *CTRL-W_.* *CTRL-W_N*
5252
CTRL-W " {reg} paste register {reg} *CTRL-W_quote*
5353
Also works with the = register to insert the result of
5454
evaluating an expression.
55+
CTRL-W CTRL-C ends the job, see below |t_CTRL-W_CTRL-C|
5556

5657
See option 'termkey' for specifying another key instead of CTRL-W that
5758
will work like CTRL-W. However, typing 'termkey' twice sends 'termkey' to
@@ -62,16 +63,29 @@ the job. For example:
6263
'termkey' . send a CTRL-W to the job in the terminal
6364
'termkey' N go to terminal Normal mode, see below
6465
'termkey' CTRL-N same as CTRL-W N
66+
'termkey' CTRL-C same as |t_CTRL-W_CTRL-C|
6567
*t_CTRL-\_CTRL-N*
6668
The special key combination CTRL-\ CTRL-N can be used to switch to Normal
6769
mode, just like this works in any other mode.
70+
*t_CTRL-W_CTRL-C*
71+
CTRL-W CTRL-C can be typed to forcefully end the job. On MS-Windows a
72+
CTRL-BREAK will also kill the job.
6873

74+
If you type CTRL-C the effect depends on what the pty has been configured to
75+
do. For simple commands this causes a SIGINT to be sent to the job, which
76+
would end it. Other commands may ignore the SIGINT or handle the CTRL-C
77+
themselves (like Vim does).
6978

70-
Size ~
79+
80+
Size and color ~
7181

7282
See option 'termsize' for controlling the size of the terminal window.
7383
(TODO: scrolling when the terminal is larger than the window)
7484

85+
The terminal uses the 'background' option to decide whether the terminal
86+
window will start with a white or black background. The job running in the
87+
terminal can change the colors.
88+
7589

7690
Syntax ~
7791

@@ -115,8 +129,8 @@ Syntax ~
115129
If you want to use more options use the |term_start()|
116130
function.
117131

118-
When the buffer associated with the terminal is wiped out the job is killed,
119-
similar to calling `job_stop(job, "kill")`
132+
When the buffer associated with the terminal is unloaded or wiped out the job
133+
is killed, similar to calling `job_stop(job, "kill")`
120134

121135
By default the 'bufhidden' option of the buffer will be set to "hide".
122136
So long as the job is running: If the window is closed the buffer becomes
@@ -130,7 +144,7 @@ done, use options like this: >
130144
Note that the window will open at an unexpected moment, this will interrupt
131145
what you are doing.
132146

133-
*E947*
147+
*E947* *E948*
134148
So long as the job is running, the buffer is considered modified and Vim
135149
cannot be quit easily, see |abandon|.
136150

@@ -187,6 +201,8 @@ In Terminal-Normal mode the statusline and window title show "(Terminal)". If
187201
the job ends while in Terminal-Normal mode this changes to
188202
"(Terminal-finished)".
189203

204+
It is not possible to enter Insert mode from Terminal-Job mode.
205+
190206

191207
Unix ~
192208

@@ -226,7 +242,10 @@ You can download them from the following page:
226242

227243
https://github.com/rprichard/winpty
228244

229-
Just put the files somewhere in your PATH.
245+
Just put the files somewhere in your PATH. You can set the 'winptydll' option
246+
to point to the right file, if needed. If you have both the 32-bit and 64-bit
247+
version, rename to winpty32.dll and winpty64.dll to match the way Vim was
248+
build.
230249

231250
==============================================================================
232251
2. Remote testing *terminal-testing*

src/terminal.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1367,9 +1367,6 @@ terminal_loop(void)
13671367
if (c == K_IGNORE)
13681368
continue;
13691369

1370-
#ifdef UNIX
1371-
may_send_sigint(c, curbuf->b_term->tl_job->jv_pid, 0);
1372-
#endif
13731370
#ifdef WIN3264
13741371
/* On Windows winpty handles CTRL-C, don't send a CTRL_C_EVENT.
13751372
* Use CTRL-BREAK to kill the job. */
@@ -1405,6 +1402,11 @@ terminal_loop(void)
14051402
/* Send both keys to the terminal. */
14061403
send_keys_to_term(curbuf->b_term, prev_c, TRUE);
14071404
}
1405+
else if (c == Ctrl_C)
1406+
{
1407+
/* "CTRL-W CTRL-C" or 'termkey' CTRL-C: end the job */
1408+
mch_signal_job(curbuf->b_term->tl_job, (char_u *)"kill");
1409+
}
14081410
else if (termkey == 0 && c == '.')
14091411
{
14101412
/* "CTRL-W .": send CTRL-W to the job */

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,8 @@ static char *(features[]) =
769769

770770
static int included_patches[] =
771771
{ /* Add new patch number below this line */
772+
/**/
773+
960,
772774
/**/
773775
959,
774776
/**/

0 commit comments

Comments
 (0)