diff options
author | Sebastian Thiel <sebastian.thiel@icloud.com> | 2020-03-29 18:41:48 +0800 |
---|---|---|
committer | Sebastian Thiel <sebastian.thiel@icloud.com> | 2020-03-29 18:41:48 +0800 |
commit | 8c3294e67c4a140be335816720d6c0e5d021319b (patch) | |
tree | 0a6c1f34b67b94b1dd4787c2dd19e5d6c18d805c | |
parent | 5f2bc2d38205cc66b7bb1805b5a1544e8ccfaae2 (diff) |
Allow deletion of files while scanning, it should yield IOerrors only; improve 'scanning' message
-rw-r--r-- | src/interactive/app/eventloop.rs | 9 | ||||
-rw-r--r-- | src/interactive/app/handlers.rs | 6 | ||||
-rw-r--r-- | src/interactive/app_test/journeys_readonly.rs | 5 |
3 files changed, 16 insertions, 4 deletions
diff --git a/src/interactive/app/eventloop.rs b/src/interactive/app/eventloop.rs index f8e68b7..c7e0945 100644 --- a/src/interactive/app/eventloop.rs +++ b/src/interactive/app/eventloop.rs @@ -35,6 +35,7 @@ pub struct AppState { pub message: Option<String>, pub focussed: FocussedPane, pub bookmarks: BTreeMap<TreeIndex, TreeIndex>, + pub is_scanning: bool, } impl AppState { @@ -72,6 +73,7 @@ impl AppState { self.draw(window, traversal, display.clone(), terminal)?; for key in keys.filter_map(Result::ok) { + self.reset_message(); match key { Char('?') => self.toggle_help_pane(window), Char('\t') => { @@ -190,7 +192,7 @@ impl TerminalApp { })), } - let fetch_buffered_key_events = || { + let fetch_buffered_key_events = move || { let mut keys = Vec::new(); while let Ok(key) = keys_rx.try_recv() { keys.push(key); @@ -208,8 +210,8 @@ impl TerminalApp { AppState { root: traversal.root_index, sorting, - message: Some("-> scanning <-".into()), entries: sorted_entries(&traversal.tree, traversal.root_index, sorting), + is_scanning: true, ..Default::default() } }); @@ -225,6 +227,7 @@ impl TerminalApp { )?; Ok(()) })?; + drop(fetch_buffered_key_events); // shutdown input event handler early for good measure display.byte_vis = ByteVisualization::PercentageAndBar; Ok(TerminalApp { @@ -240,7 +243,7 @@ impl TerminalApp { ..Default::default() } }); - s.reset_message(); + s.is_scanning = false; s.entries = sorted_entries(&traversal.tree, s.root, s.sorting); s.selected = s.selected.or_else(|| s.entries.get(0).map(|b| b.index)); s diff --git a/src/interactive/app/handlers.rs b/src/interactive/app/handlers.rs index e01b710..89041d7 100644 --- a/src/interactive/app/handlers.rs +++ b/src/interactive/app/handlers.rs @@ -143,7 +143,11 @@ impl AppState { } pub fn reset_message(&mut self) { - self.message = None; + if self.is_scanning { + self.message = Some("-> scanning <-".into()); + } else { + self.message = None; + } } pub fn toggle_help_pane(&mut self, window: &mut MainWindow) { diff --git a/src/interactive/app_test/journeys_readonly.rs b/src/interactive/app_test/journeys_readonly.rs index 7acc85a..9461265 100644 --- a/src/interactive/app_test/journeys_readonly.rs +++ b/src/interactive/app_test/journeys_readonly.rs @@ -27,6 +27,11 @@ fn simple_user_journey_read_only() -> Result<(), Error> { "it will sort entries in descending order by size" ); + assert_eq!( + app.state.is_scanning, false, + "it will not think it is still scanning" + ); + let first_selected_path = OsString::from(format!("{}/{}", FIXTURE_PATH, long_root)); assert_eq!( node_by_name(&app, &first_selected_path).name, |