diff options
author | Sebastian Thiel <sthiel@thoughtworks.com> | 2019-06-16 12:17:35 +0800 |
---|---|---|
committer | Sebastian Thiel <sthiel@thoughtworks.com> | 2019-06-16 12:17:35 +0800 |
commit | d9dcbd0f89c1267f272f3cd7e9f9dd69d0ae145b (patch) | |
tree | 2e367e52c907c60c789de30abc063539355497ad /src/interactive | |
parent | 81dc53b0e6d7c292909610fba6fd030ed6b01917 (diff) |
performance improvementsv2.1.2
Diffstat (limited to 'src/interactive')
-rw-r--r-- | src/interactive/app/common.rs | 5 | ||||
-rw-r--r-- | src/interactive/app/eventloop.rs | 3 | ||||
-rw-r--r-- | src/interactive/app/handlers.rs | 2 | ||||
-rw-r--r-- | src/interactive/widgets/entries.rs | 10 |
4 files changed, 14 insertions, 6 deletions
diff --git a/src/interactive/app/common.rs b/src/interactive/app/common.rs index c612f28..6338f25 100644 --- a/src/interactive/app/common.rs +++ b/src/interactive/app/common.rs @@ -39,11 +39,12 @@ pub fn sorted_entries(tree: &Tree, node_idx: TreeIndex, sorting: SortMode) -> Ve .filter_map(|idx| { tree.node_weight(idx).map(|w| { let p = path_of(tree, idx); + let pm = p.metadata(); EntryDataBundle { index: idx, data: w.clone(), - is_dir: p.is_dir(), - exists: p.exists(), + exists: pm.is_ok(), + is_dir: pm.ok().map_or(false, |m| m.is_dir()), } }) }) diff --git a/src/interactive/app/eventloop.rs b/src/interactive/app/eventloop.rs index a85ad1e..38533a2 100644 --- a/src/interactive/app/eventloop.rs +++ b/src/interactive/app/eventloop.rs @@ -8,8 +8,7 @@ use dua::{ WalkOptions, WalkResult, }; use failure::Error; -use std::collections::BTreeMap; -use std::{io, path::PathBuf}; +use std::{collections::BTreeMap, io, path::PathBuf}; use termion::event::Key; use tui::backend::Backend; use tui_react::Terminal; diff --git a/src/interactive/app/handlers.rs b/src/interactive/app/handlers.rs index 976a53b..0d6aa4e 100644 --- a/src/interactive/app/handlers.rs +++ b/src/interactive/app/handlers.rs @@ -134,7 +134,7 @@ impl TerminalApp { } pub fn change_entry_selection(&mut self, direction: CursorDirection) { - let entries = sorted_entries(&self.traversal.tree, self.state.root, self.state.sorting); + let entries = &self.state.entries; let next_selected_pos = match self.state.selected { Some(ref selected) => entries .iter() diff --git a/src/interactive/widgets/entries.rs b/src/interactive/widgets/entries.rs index 006673c..ed2c001 100644 --- a/src/interactive/widgets/entries.rs +++ b/src/interactive/widgets/entries.rs @@ -65,7 +65,15 @@ impl Entries { .unwrap_or_else(|_| String::from(".")), p => p, }; - let title = format!(" {} ", title); + let title = format!( + " {} ({} item{})", + title, + entries.len(), + match entries.len() { + 1 => "", + _ => "s", + } + ); let block = Block::default() .title(&title) .border_style(*border_style) |