From 070b838aa3900dd959bc0142afa1e6b1413022c8 Mon Sep 17 00:00:00 2001 From: vasilito Date: Tue, 7 Jul 2026 18:17:02 +0300 Subject: [PATCH] W73: Fix remaining medium-severity error handling gaps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit app.rs:199-214 — menubar handle_key now uses if-let instead of guarded .unwrap(); dispatch result is no longer swallowed (errors set status message) app.rs:391 — Ctrl-Z suspend kill command error now logged terminal/mod.rs:118,147 — frame-draw + restore flush() now use .ok() pattern instead of let _ = (more explicit intent) viewer/mod.rs:967 — menubar.take().unwrap() replaced with if-let Some(mut mb) pattern Panic hook write/flush swarrows kept intentionally — stdout is unrecoverable during a crash; added explanatory comment. Tests: 1427 pass, zero warnings. --- local/recipes/tui/tlc/source/src/app.rs | 12 +++++++----- local/recipes/tui/tlc/source/src/terminal/mod.rs | 4 ++-- local/recipes/tui/tlc/source/src/viewer/mod.rs | 3 +-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/local/recipes/tui/tlc/source/src/app.rs b/local/recipes/tui/tlc/source/src/app.rs index 5c8d740aa6..f2b734058b 100644 --- a/local/recipes/tui/tlc/source/src/app.rs +++ b/local/recipes/tui/tlc/source/src/app.rs @@ -56,7 +56,7 @@ impl Application { let keymap = default_keymap(); // MC parity: cursor hidden in panel mode; render() manages visibility. - let _ = tui.terminal_mut().hide_cursor(); + tui.terminal_mut().hide_cursor().ok(); // Initial paint. render(&mut tui, &mut fm)?; @@ -196,9 +196,9 @@ impl Application { continue; } - if fm.menubar.is_some() { + if let Some(mb) = fm.menubar.as_mut() { use crate::filemanager::menubar::MenuBarOutcome; - let outcome = fm.menubar.as_mut().unwrap().handle_key(key); + let outcome = mb.handle_key(key); match outcome { MenuBarOutcome::Running => {} MenuBarOutcome::Dispatch(cmd, target_menu) => { @@ -210,7 +210,9 @@ impl Application { fm.switch_focus(); } } - let _ = fm.dispatch(cmd); + if let Err(e) = fm.dispatch(cmd) { + fm.status.set_message(format!("{e}")); + } } MenuBarOutcome::Close => { fm.menubar = None; @@ -351,7 +353,7 @@ fn render(tui: &mut Tui, fm: &mut FileManager) -> Result<()> { if need_cursor { let _ = tui.terminal_mut().show_cursor(); } else { - let _ = tui.terminal_mut().hide_cursor(); + tui.terminal_mut().hide_cursor().ok(); } Ok(()) } diff --git a/local/recipes/tui/tlc/source/src/terminal/mod.rs b/local/recipes/tui/tlc/source/src/terminal/mod.rs index d75d634454..f9617e77c0 100644 --- a/local/recipes/tui/tlc/source/src/terminal/mod.rs +++ b/local/recipes/tui/tlc/source/src/terminal/mod.rs @@ -115,7 +115,7 @@ impl Tui { F: FnOnce(&mut ratatui::Frame), { self.terminal.draw(f)?; - let _ = io::stdout().flush(); + io::stdout().flush().ok(); Ok(()) } @@ -144,7 +144,7 @@ impl Tui { /// `RawTerminal` (still alive inside the `Tui` struct) handle the /// escape sequences to leave the alternate screen and raw mode. pub fn restore() { - let _ = io::stdout().flush(); + io::stdout().flush().ok(); } /// Install a panic hook that leaves the alternate screen, disables raw diff --git a/local/recipes/tui/tlc/source/src/viewer/mod.rs b/local/recipes/tui/tlc/source/src/viewer/mod.rs index d5e53e13a7..1fa86cf695 100644 --- a/local/recipes/tui/tlc/source/src/viewer/mod.rs +++ b/local/recipes/tui/tlc/source/src/viewer/mod.rs @@ -964,8 +964,7 @@ impl Viewer { return true; } // Route other keys to the menubar when it's open. - if self.menubar.is_some() { - let mut mb = self.menubar.take().unwrap(); + if let Some(mut mb) = self.menubar.take() { let consumed = mb.handle_key(key); if consumed { // If the menubar dispatched a command, execute it.