W73: Fix remaining medium-severity error handling gaps

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.
This commit is contained in:
2026-07-07 18:17:02 +03:00
parent 51d790c218
commit 070b838aa3
3 changed files with 10 additions and 9 deletions
+7 -5
View File
@@ -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(())
}
@@ -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
@@ -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.