aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/tui
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-02-02 22:42:15 +0800
committerGitHub <noreply@github.com>2023-02-02 22:42:15 +0800
commitd3355ad01c3b9d1dbc62210c29d8e51245f081aa (patch)
treecf36953fd1f5d5bdec4681c5ea2ab31eb2bbecd2 /src/nvim/tui
parentcbf9199d65325c1167d7eeb02a34c85d243e781c (diff)
downloadrneovim-d3355ad01c3b9d1dbc62210c29d8e51245f081aa.tar.gz
rneovim-d3355ad01c3b9d1dbc62210c29d8e51245f081aa.tar.bz2
rneovim-d3355ad01c3b9d1dbc62210c29d8e51245f081aa.zip
fix(tui): detach/attach on suspend/resume (#22040)
Problem: When a TUI client is suspended it still receives UI events from the server, and has to process these accumulated events when it is resumed. With mulitple TUI clients this is a bigger problem, considering the following steps: 1. A TUI client is attached. 2. CTRL-Z is pressed and the first client is suspended. 3. Another TUI client is attached. 4. CTRL-Z is pressed and a "suspend" event is sent to both clients. The second client is suspended, while the first client isn't able to process the event because it has already been suspended. 5. The first client is resumed. It processes the accumulated "suspend" event and suspends immediately. Solution: Make a TUI client detach on suspend and re-attach on resume.
Diffstat (limited to 'src/nvim/tui')
-rw-r--r--src/nvim/tui/tui.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c
index ceda3b2076..f760e99262 100644
--- a/src/nvim/tui/tui.c
+++ b/src/nvim/tui/tui.c
@@ -1347,6 +1347,7 @@ static void show_verbose_terminfo(TUIData *tui)
static void suspend_event(void **argv)
{
TUIData *tui = argv[0];
+ ui_client_detach();
bool enable_mouse = tui->mouse_enabled;
tui_terminal_stop(tui);
stream_set_blocking(tui->input.in_fd, true); // normalize stream (#2598)
@@ -1359,6 +1360,7 @@ static void suspend_event(void **argv)
tui_mouse_on(tui);
}
stream_set_blocking(tui->input.in_fd, false); // libuv expects this
+ ui_client_attach(tui->width, tui->height, tui->term);
}
#endif