neovim/test/functional/terminal
neovim-backports[bot] 316fa168a1
fix(terminal): interrupt/got_int hangs terminal (#30094)
fix(terminal): interrupt/got_int hangs terminal (#30056)

Upon `terminal_enter`, `mapped_ctrl_c` is set in order to avoid `CTRL-C`
interrupts (which is proxied to the terminal process instead), `os_inchar`
will then test `mapped_ctrl_c` against `State` and set `ctrl_c_interrupts=false`
which prevents `process_ctrl_c` from setting `got_int=true` in a terminal
state.

However, if `got_int` is set outside of `process_ctrl_c`, e.g. via
`interrupt()`, this will hang the neovim process as `terminal_execute` will
enter an endless loop as `got_int` will never be cleared causing `safe_vgetc`
to always return `Ctrl_C`.

A minimal example reproducing this bug:
```vim
:autocmd TermEnter * call timer_start(500, {-> interrupt()})
:terminal
:startinsert
```

To fix, we make sure `got_int` is cleared inside `terminal_execute` when
it detects `Ctrl_C`.

Closes #20726

Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Co-authored-by: ibhagwan <59988195+ibhagwan@users.noreply.github.com>
2024-08-20 06:48:13 +08:00
..
altscreen_spec.lua test: improve test conventions 2024-04-23 18:17:04 +02:00
api_spec.lua test: improve test conventions 2024-04-23 18:17:04 +02:00
buffer_spec.lua fix(terminal): interrupt/got_int hangs terminal (#30094) 2024-08-20 06:48:13 +08:00
channel_spec.lua test: improve test conventions 2024-04-23 18:17:04 +02:00
cursor_spec.lua test: improve test conventions 2024-04-23 18:17:04 +02:00
edit_spec.lua test: improve test conventions 2024-04-23 18:17:04 +02:00
ex_terminal_spec.lua test: improve test conventions 2024-04-23 18:17:04 +02:00
highlight_spec.lua test: improve test conventions 2024-04-23 18:17:04 +02:00
mouse_spec.lua test: improve test conventions 2024-04-23 18:17:04 +02:00
scrollback_spec.lua test: improve test conventions 2024-04-23 18:17:04 +02:00
testutil.lua fix(ui): avoid ambiguity about last chunk when flushing halfway (#29718) 2024-07-15 10:35:38 +00:00
tui_spec.lua fix(tui): set id parameter in OSC 8 sequences (#29847) 2024-07-24 15:18:47 -05:00
window_spec.lua test: improve test conventions 2024-04-23 18:17:04 +02:00
window_split_tab_spec.lua test: improve test conventions 2024-04-23 18:17:04 +02:00