fix: reorder the exit of enhanced keyboard mode (#1694)

The `Stdout::new` function first enters an alternate
screen then later enables enhanced keyboard mode.

In `Drop`, we need to do this in the opposite order:
disable enhanced keyboard mode then exit alternate mode.

Fixes #1693
This commit is contained in:
Andrew Lee 2024-02-12 01:24:24 -07:00 committed by GitHub
parent 5738d06282
commit f96cb6903d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -794,6 +794,9 @@ impl Stdout {
impl Drop for Stdout {
fn drop(&mut self) {
#[cfg(not(target_os = "windows"))]
execute!(self.stdout, PopKeyboardEnhancementFlags).unwrap();
if !self.inline_mode {
execute!(self.stdout, terminal::LeaveAlternateScreen).unwrap();
}
@ -804,9 +807,6 @@ impl Drop for Stdout {
)
.unwrap();
#[cfg(not(target_os = "windows"))]
execute!(self.stdout, PopKeyboardEnhancementFlags).unwrap();
terminal::disable_raw_mode().unwrap();
}
}