aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Sicong Jiang <KevinSJ@users.noreply.github.com>2022-06-19 20:22:39 +0500
committerGitHub <noreply@github.com>2022-06-19 08:22:39 -0700
commit837ea6da9f65ac4ec85421c6e4af15194cc222d0 (patch)
tree01ee37ba3085eb8dbf6b1abf186650c77fe730c2
parentc5c5d980a1e2b758048cf6310ccf97807c575a63 (diff)
downloadrneovim-837ea6da9f65ac4ec85421c6e4af15194cc222d0.tar.gz
rneovim-837ea6da9f65ac4ec85421c6e4af15194cc222d0.tar.bz2
rneovim-837ea6da9f65ac4ec85421c6e4af15194cc222d0.zip
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
-rw-r--r--src/nvim/ui.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/nvim/ui.c b/src/nvim/ui.c
index bdcb7af7e9..3e715793e6 100644
--- 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;