Skip to content

Commit cc36961

Browse files
committed
Fix busy state
1 parent a338a99 commit cc36961

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/textui/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,4 +230,10 @@ impl App {
230230
self.add_message("Reset MEGA65");
231231
Ok(())
232232
}
233+
234+
/// Unselect any selected CBM and file action
235+
pub fn unselect_all(&mut self) {
236+
self.cbm_browser.unselect();
237+
self.file_action.unselect();
238+
}
233239
}

src/textui/terminal.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ fn run_app<B: Backend>(terminal: &mut Terminal<B>, mut app: App) -> Result<()> {
7373
KeyCode::Down => app.next_item(),
7474
// We check for ENTER twice in order to allow update display to/from BUSY state
7575
KeyCode::Enter => {
76-
if app.cbm_browser.is_selected() {
76+
if app.cbm_browser.is_selected() | app.file_action.is_selected() {
7777
app.busy = true;
7878
terminal.draw(|f| ui::ui(f, &mut app))?;
7979
} else {
@@ -92,12 +92,13 @@ fn run_app<B: Backend>(terminal: &mut Terminal<B>, mut app: App) -> Result<()> {
9292
},
9393
_ => Ok(()),
9494
};
95+
// Gracefully pick up errors and show them in the msg widget
9596
match result {
9697
Ok(()) => {}
9798
Err(error) => {
9899
app.add_message(error.to_string().as_str());
99-
app.cbm_browser.unselect();
100100
app.active_widget = AppWidgets::FileSelector;
101+
app.unselect_all();
101102
}
102103
}
103104
}

0 commit comments

Comments
 (0)