From de065dad2d48b0d60135b16bff547586bd753f68 Mon Sep 17 00:00:00 2001 From: Tim Allen Date: Sun, 17 May 2020 20:32:25 +1000 Subject: [PATCH] terminal_ui: restore termios settings before suspending Kakoune. TerminalUI::suspend() is responsible for undoing all Kakoune's modifications to the terminal state, actually suspending the process, then re-applying all the modifications after Kakoune wakes back up. Previously, the "undo" and "reapply" steps for termios settings were both after the suspend point, so on some platforms they were incorrect when the user arrived back at the shell prompt. Now, the termios "undo" step is back before the suspend point, and the undo and reapply steps should be in exactly reversed order. Fixes #3488. --- src/terminal_ui.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/terminal_ui.cc b/src/terminal_ui.cc index 6b2a5966..40cca53a 100644 --- a/src/terminal_ui.cc +++ b/src/terminal_ui.cc @@ -398,6 +398,7 @@ void TerminalUI::suspend() { bool mouse_enabled = m_mouse_enabled; enable_mouse(false); + tcsetattr(STDIN_FILENO, TCSAFLUSH, &m_original_termios); restore_terminal(); auto current = set_signal_handler(SIGTSTP, SIG_DFL); @@ -408,7 +409,6 @@ void TerminalUI::suspend() raise(SIGTSTP); // suspend here - tcsetattr(STDIN_FILENO, TCSAFLUSH, &m_original_termios); set_signal_handler(SIGTSTP, current); sigprocmask(SIG_SETMASK, &old_mask, nullptr);