From ef6d75c23a229a1a7fec5d695cdbc502eea81236 Mon Sep 17 00:00:00 2001 From: Joscha Date: Thu, 25 Apr 2024 19:56:09 +0200 Subject: [PATCH] Fix suspend sequence In my kitty-based setup, I observed the following bug: 1. Run cove[1], a toss-based application, in a kitty tab 2. Exit cove 3. Start lazygit[2] 4. Stage some files and enter a commit message 5. Try to press enter and observe garbage appearing in the text box The bug occurred reliably after running cove, but never occurred if cove was not run in that tab. This commit fixes the bug by making the suspend sequence undo the unsuspend sequence's steps in reverse order. --- CHANGELOG.md | 1 + src/terminal.rs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a01f614..a466408 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ Procedure when bumping the version number: ### Fixed - Width measurements of ASCII control characters +- Toss messing up the terminal state ## v0.2.2 - 2024-01-14 diff --git a/src/terminal.rs b/src/terminal.rs index 545a701..33c37fa 100644 --- a/src/terminal.rs +++ b/src/terminal.rs @@ -68,12 +68,12 @@ impl Terminal { /// presenting the next frame. pub fn suspend(&mut self) -> io::Result<()> { crossterm::terminal::disable_raw_mode()?; - self.out.execute(LeaveAlternateScreen)?; #[cfg(not(windows))] { - self.out.execute(DisableBracketedPaste)?; self.out.execute(PopKeyboardEnhancementFlags)?; + self.out.execute(DisableBracketedPaste)?; } + self.out.execute(LeaveAlternateScreen)?; self.out.execute(Show)?; Ok(()) }