diff options
author | Felipe Morales <hel.sheep@gmail.com> | 2015-08-08 15:55:18 -0300 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2015-08-10 00:01:27 -0400 |
commit | 7d9472ab1b7dc4eb2bb838fb8febcc7a1aab649d (patch) | |
tree | 3025e7a4db43e22ef172a084963bb9c6574c5679 | |
parent | 389c3b8581e0b69a987fecb2b9f9ebaa15746c2d (diff) | |
download | rneovim-7d9472ab1b7dc4eb2bb838fb8febcc7a1aab649d.tar.gz rneovim-7d9472ab1b7dc4eb2bb838fb8febcc7a1aab649d.tar.bz2 rneovim-7d9472ab1b7dc4eb2bb838fb8febcc7a1aab649d.zip |
tui: avoid double-resize on SIGWINCH. #3145
-rw-r--r-- | src/nvim/tui/tui.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 56bdc73bc5..28870b5abb 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -66,6 +66,8 @@ typedef struct { } unibi_ext; } TUIData; +static bool volatile got_winch = false; + #ifdef INCLUDE_GENERATED_DECLARATIONS # include "tui/tui.c.generated.h" #endif @@ -212,6 +214,7 @@ static void try_resize(Event ev) static void sigwinch_cb(SignalWatcher *watcher, int signum, void *data) { + got_winch = true; // Queue the event because resizing can result in recursive event_poll calls // FIXME(blueyed): TUI does not resize properly when not deferred. Why? #2322 loop_push_event(&loop, (Event) { @@ -354,10 +357,13 @@ static void tui_resize(UI *ui, int width, int height) data->scroll_region.right = width - 1; data->row = data->col = 0; - // try to resize the terminal window - char r[16]; // enough for 9999x9999 - snprintf(r, sizeof(r), "\x1b[8;%d;%dt", height, width); - out(ui, r, strlen(r)); + if (!got_winch) { // Try to resize the terminal window. + char r[16]; // enough for 9999x9999 + snprintf(r, sizeof(r), "\x1b[8;%d;%dt", height, width); + out(ui, r, strlen(r)); + } else { // Already handled the SIGWINCH signal; avoid double-resize. + got_winch = false; + } } static void tui_clear(UI *ui) |