From fe3006aefcdc4c22924e7bce966b2c430dade4f1 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Wed, 12 Aug 2026 06:55:56 +0100 Subject: [PATCH] term: reset more state on RIS full reset When a program turns on modifyOtherKeys and exits uncleanly, it can leave ctrl keys emitting escape sequences the shell doesn't understand. The obvious recovery is the "Reset the terminal emulation state in the current pane" command in the command palette, which sends RIS. However, RIS wasn't clearing modifyOtherKeys, so it didn't help. This commit fixes RIS to reset that state, and a sweep for the same kind of omission turned up missing resets for left/right margin mode and bidi overrides, which it now resets too. This brings RIS in line with the state a soft reset (DECSTR) already clears. --- docs/changelog.md | 4 ++++ term/src/terminalstate/performer.rs | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/docs/changelog.md b/docs/changelog.md index dd95f31ec..e3eeb945a 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -152,6 +152,10 @@ As features stabilize some brief notes about them will accumulate here. search matching. Thanks to @mrdziuban! #7385 #### Fixed +* `ResetTerminal` (RIS) did not reset the `modifyOtherKeys` state. A program + that left it enabled and exited uncleanly could leave ctrl keys emitting + escape sequences that the shell doesn't expect. RIS now also resets the + left/right margin mode and bidi state. * Race condition when very quickly adjusting font scale, and other improvements around resizing. Thanks to @jknockel! #4876 #5032 #5033 * macOS: wacky initial window size with external monitors or certain font diff --git a/term/src/terminalstate/performer.rs b/term/src/terminalstate/performer.rs index 4acbe6cff..25cdec6a5 100644 --- a/term/src/terminalstate/performer.rs +++ b/term/src/terminalstate/performer.rs @@ -698,6 +698,7 @@ impl<'a> Performer<'a> { self.mouse_tracking = false; self.mouse_encoding = MouseEncoding::X10; self.keyboard_encoding = KeyboardEncoding::Xterm; + self.modify_other_keys = None; self.sixel_scrolls_right = false; self.any_event_mouse = false; self.button_event_mouse = false; @@ -711,6 +712,9 @@ impl<'a> Performer<'a> { self.palette.take(); self.top_and_bottom_margins = 0..self.screen().physical_rows as VisibleRowIndex; self.left_and_right_margins = 0..self.screen().physical_cols; + self.left_and_right_margin_mode = false; + self.bidi_enabled.take(); + self.bidi_hint.take(); self.unicode_version = self.config.unicode_version(); self.unicode_version_stack.clear(); self.suppress_initial_title_change = false;