diff options
author | Sebastian Thiel <sthiel@thoughtworks.com> | 2019-06-07 03:15:11 +0530 |
---|---|---|
committer | Sebastian Thiel <sthiel@thoughtworks.com> | 2019-06-07 03:15:11 +0530 |
commit | 5cff69c47a5b92017e6b1c55a35fd97f08ab3181 (patch) | |
tree | 3b068edaeef0cf1ca2c94f05b3d9647113ce7ae9 /src/interactive/widgets | |
parent | 65321d786aa105f3f99ea43144f9f4b5a4ee4574 (diff) |
see how it is when sorting by alphabet
It's what yuou want when deleting things, but not when displaying them.
Diffstat (limited to 'src/interactive/widgets')
-rw-r--r-- | src/interactive/widgets/mark.rs | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/src/interactive/widgets/mark.rs b/src/interactive/widgets/mark.rs index 40bf959..8479741 100644 --- a/src/interactive/widgets/mark.rs +++ b/src/interactive/widgets/mark.rs @@ -1,6 +1,7 @@ use crate::interactive::{widgets::COLOR_MARKED_LIGHT, CursorDirection, EntryMark, EntryMarkMap}; use dua::path_of; use dua::traverse::{Tree, TreeIndex}; +use itertools::Itertools; use std::borrow::Borrow; use termion::{event::Key, event::Key::*}; use tui::{ @@ -26,6 +27,7 @@ pub struct MarkPaneProps { } impl MarkPane { + #[cfg(test)] pub fn has_focus(&self) -> bool { self.has_focus } @@ -92,21 +94,25 @@ impl MarkPane { .map(|selected| selected) .or(Some(marked.len().saturating_sub(1))); let selected = self.selected; - let entries = marked.values().enumerate().map(|(idx, v)| { - let modifier = match selected { - Some(selected) if idx == selected => Modifier::BOLD, - _ => Modifier::empty(), - }; - let name = Text::Styled( - v.path.to_string_lossy(), - Style { - fg: COLOR_MARKED_LIGHT, - modifier, - ..Style::default() - }, - ); - vec![name] - }); + let entries = marked + .values() + .sorted_by_key(|v| &v.path) + .enumerate() + .map(|(idx, v)| { + let modifier = match selected { + Some(selected) if idx == selected => Modifier::BOLD, + _ => Modifier::empty(), + }; + let name = Text::Styled( + v.path.to_string_lossy(), + Style { + fg: COLOR_MARKED_LIGHT, + modifier, + ..Style::default() + }, + ); + vec![name] + }); let props = ListProps { block: Some(block), |