Skip to content

Commit 4bafe61

Browse files
authored
Merge pull request #856 from ychin/ctrl-c-interrupt-fix
Fix MacVim Ctrl-C handling in Normal and Command-Line modes
2 parents caed4ee + 066dd1f commit 4bafe61

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/MacVim/MMBackend.m

+10-8
Original file line numberDiff line numberDiff line change
@@ -1270,17 +1270,19 @@ - (oneway void)processInput:(int)msgid data:(in bycopy NSData *)data
12701270
unsigned len = *((unsigned*)bytes); bytes += sizeof(unsigned);
12711271

12721272
if (ctrl_c_interrupts && 1 == len) {
1273-
// NOTE: the flag ctrl_c_interrupts is 0 e.g. when the user has
1274-
// mappings to something like <C-c>g. Also it seems the flag
1275-
// intr_char is 0 when MacVim was started from Finder whereas it is
1276-
// 0x03 (= Ctrl_C) when started from Terminal.
1273+
// NOTE: The flag ctrl_c_interrupts is set when it has special
1274+
// interrupt behavior in Vim and would cancel all other input. This
1275+
// is a hard-coded behavior in Vim. It usually happens when not in
1276+
// Insert mode, and when <C-C> is not mapped in the current mode
1277+
// (even if <C-C> is mapped to itself, ctrl_c_interrupts would not
1278+
// be set).
1279+
// Also it seems the flag intr_char is 0 when MacVim was started
1280+
// from Finder whereas it is 0x03 (= Ctrl_C) when started from
1281+
// Terminal.
12771282
char_u *str = (char_u*)bytes;
12781283
if (str[0] == Ctrl_C || (str[0] == intr_char && intr_char != 0)) {
1279-
ASLogDebug(@"Got INT, str[0]=%#x ctrl_c_interrupts=%d "
1280-
"intr_char=%#x", str[0], ctrl_c_interrupts, intr_char);
1284+
trash_input_buf();
12811285
got_int = TRUE;
1282-
[inputQueue removeAllObjects];
1283-
return;
12841286
}
12851287
}
12861288

0 commit comments

Comments
 (0)