commit 837ea6da9f65ac4ec85421c6e4af15194cc222d0
parent c5c5d980a1e2b758048cf6310ccf97807c575a63
Author: Kevin Sicong Jiang <KevinSJ@users.noreply.github.com>
Date: Sun, 19 Jun 2022 20:22:39 +0500
fix(tui): piping nodejs to nvim breaks input handling #18932
Problem:
Piping NodeJS output into Neovim makes the editor unusable.
This happens because NodeJS changes the tty state on exit after
Nvim calls uv_tty_set_mode(). (May not always happen due to race
condition.)
This should have been fixed by 4ba5b4a86461 #13084. But some
commands and functions (:sleep, system(), …) call ui_flush()
internally, in particular the first tui_mode_change() is called before
the end of startup.
Steps to reproduce:
1. node -e "setTimeout(()=>{console.log('test')}, 1000)" | nvim -u NORC +"sleep 500m" -
2. The cursor key letters just overwrite the editor screen, and CTRL+C exits.
Solution:
Skip pending_mode_update during startup.
Note: Delaying ui_flush() entirely could be a more general solution
(emit a new UI event on VimEnter?). But "remote/coprocess TUI" #18375
could make all of this moot anyway.
Fixes #18470
Diffstat:
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/nvim/ui.c b/src/nvim/ui.c
@@ -514,7 +514,7 @@ void ui_flush(void)
api_free_array(style);
pending_mode_info_update = false;
}
- if (pending_mode_update) {
+ if (pending_mode_update && !starting) {
char *full_name = shape_table[ui_mode_idx].full_name;
ui_call_mode_change(cstr_as_string(full_name), ui_mode_idx);
pending_mode_update = false;