diff options
| author | Can Celik <ogulcancelik@gmail.com> | 2026-08-19 04:43:28 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-08-19 04:43:28 +0300 |
| commit | a5c69beabfc82d9c3f9563eb821139b2e0f3e14f (patch) | |
| tree | 9b7049e4629913dcab40d985df399acee262b67b /src/pane.rs | |
| parent | 3667151744e379ac5c8f76d57203b675de8a6ebc (diff) | |
fix(perf): eliminate redundant terminal wake work (#2962)
* fix(perf): eliminate redundant terminal wake work
* fix(perf): harden release benchmark gate
* test(perf): strengthen performance guardrails
Diffstat (limited to 'src/pane.rs')
| -rw-r--r-- | src/pane.rs | 49 |
1 files changed, 32 insertions, 17 deletions
diff --git a/src/pane.rs b/src/pane.rs index 0b3edf7d..b2e1603d 100644 --- a/src/pane.rs +++ b/src/pane.rs @@ -40,6 +40,8 @@ use self::agent_detection::{ DetectionScreenReadInput, PendingIdleConfirmation, ScreenDetectionPublishInput, AGENT_PENDING_IDLE_RECHECK, AGENT_STARTUP_GRACE_WINDOW, }; +#[cfg(any(unix, test))] +pub use self::terminal::InputState; use self::terminal::{GhosttyPaneTerminal, PaneTerminal}; pub(crate) use self::terminal::{ TerminalDirtyPatch, TerminalDirtyPatchOutcome, TerminalReadSnapshot, TerminalTextMatch, @@ -47,7 +49,7 @@ pub(crate) use self::terminal::{ }; pub use self::{ state::PaneState, - terminal::{InputState, ScrollMetrics, TerminalCursorState}, + terminal::{ScrollMetrics, TerminalCursorState}, }; const RELEASE_REACQUIRE_SUPPRESSION: std::time::Duration = std::time::Duration::from_secs(1); @@ -1671,11 +1673,7 @@ impl PaneRuntime { #[cfg(unix)] pub fn handoff_history_ansi(&self) -> Option<String> { - if self - .terminal - .input_state() - .is_some_and(|input_state| input_state.alternate_screen) - { + if self.terminal.alternate_screen_active() { return None; } self.snapshot_history().map(|history| { @@ -2688,12 +2686,37 @@ impl PaneRuntime { self.terminal.word_motion_target(row, col, motion) } + #[cfg(any(unix, test))] pub fn input_state(&self) -> Option<InputState> { #[cfg(test)] AGGREGATE_INPUT_STATE_READS.set(AGGREGATE_INPUT_STATE_READS.get() + 1); self.terminal.input_state() } + pub fn keyboard_report_all_requested(&self) -> bool { + self.terminal.keyboard_report_all_requested() + } + + pub fn bracketed_paste_enabled(&self) -> bool { + self.terminal.bracketed_paste_enabled() + } + + pub fn focus_reporting_enabled(&self) -> bool { + self.terminal.focus_reporting_enabled() + } + + pub fn mouse_reporting_enabled(&self) -> bool { + self.terminal.mouse_reporting_enabled() + } + + pub fn sgr_pixel_mouse_enabled(&self) -> bool { + self.terminal.sgr_pixel_mouse_enabled() + } + + pub fn plain_page_keys_use_host_scrollback(&self) -> Option<bool> { + self.terminal.plain_page_keys_use_host_scrollback() + } + pub fn alternate_screen_active(&self) -> bool { self.terminal.alternate_screen_active() } @@ -2831,10 +2854,7 @@ impl PaneRuntime { } fn paste_payload(&self, text: String) -> Bytes { - let bracketed = self - .input_state() - .map(|state| state.bracketed_paste) - .unwrap_or(false); + let bracketed = self.bracketed_paste_enabled(); let payload = if bracketed { format!("\x1b[200~{text}\x1b[201~") } else { @@ -2844,11 +2864,7 @@ impl PaneRuntime { } pub fn try_send_focus_event(&self, event: crate::ghostty::FocusEvent) -> bool { - if !self - .input_state() - .map(|state| state.focus_reporting) - .unwrap_or(false) - { + if !self.focus_reporting_enabled() { return false; } @@ -2881,7 +2897,7 @@ impl PaneRuntime { position: crate::input::mouse::Position, modifiers: crossterm::event::KeyModifiers, ) -> Option<Vec<u8>> { - if !self.input_state()?.mouse_protocol_mode.reporting_enabled() { + if !self.mouse_reporting_enabled() { return None; } self.terminal.encode_mouse_button(kind, position, modifiers) @@ -2919,7 +2935,6 @@ impl PaneRuntime { &self, kind: crossterm::event::MouseEventKind, ) -> Option<Vec<u8>> { - self.input_state()?; if self.wheel_routing()? != WheelRouting::AlternateScroll { return None; } |
