From 5fb15da5efb1be2c5edc62ce534f509286e79410 Mon Sep 17 00:00:00 2001 From: l0ng-ai <24760907+l0ng-ai@users.noreply.github.com> Date: Thu, 1 Oct 2026 15:03:11 +0800 Subject: [PATCH] style(core): settle the clippy warnings the interrupt-key reader brought in MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `is_interrupt_key` is only asked by the tests since the Grok Build change went through `interrupts`, and two `let … else { return None }` read the kitty-protocol key; the first is test-only now and the other two use `?`. --- crates/tty7-core/src/daemon/pane.rs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/crates/tty7-core/src/daemon/pane.rs b/crates/tty7-core/src/daemon/pane.rs index fe005a4d..271e1038 100644 --- a/crates/tty7-core/src/daemon/pane.rs +++ b/crates/tty7-core/src/daemon/pane.rs @@ -790,6 +790,7 @@ pub(crate) const AGENT_STALE_AFTER: Duration = Duration::from_secs(30 * 60); /// kitty keyboard protocol and xterm `modifyOtherKeys` forms a TUI may have /// switched the terminal into. Only a whole write counts — the key arrives on /// its own, and a paste that happens to hold `0x03` is not a keypress. +#[cfg(test)] fn is_interrupt_key(bytes: &[u8]) -> bool { interrupt_key(bytes).is_some() } @@ -818,21 +819,15 @@ fn interrupt_key(bytes: &[u8]) -> Option { b"\x03" | b"\x1b[27;5;99~" => return Some(InterruptKey::CtrlC), _ => {} } - let Some(body) = bytes + let body = bytes .strip_prefix(b"\x1b[") .and_then(|b| b.strip_suffix(b"u")) - .and_then(|b| std::str::from_utf8(b).ok()) - else { - return None; - }; + .and_then(|b| std::str::from_utf8(b).ok())?; let mut fields = body.split(';'); - let Some(code) = fields + let code = fields .next() .and_then(|f| f.split(':').next()) - .and_then(|c| c.parse::().ok()) - else { - return None; - }; + .and_then(|c| c.parse::().ok())?; let mut modifiers = fields.next().unwrap_or("1").split(':'); let mods = modifiers .next()