diff options
author | Canop <cano.petrole@gmail.com> | 2020-12-13 16:41:35 +0100 |
---|---|---|
committer | Canop <cano.petrole@gmail.com> | 2020-12-13 17:22:07 +0100 |
commit | 2c06c7ca0a580618d932325e15d8d40e7640f24d (patch) | |
tree | 5764d009d564a514a285426be6ce497cc65660c9 /src/tree | |
parent | ee4f93f4919be4e716bb9b73476473bbc8bd7159 (diff) |
keep selection visible on unfiltering
The selection was sometimes scrolled away on unfiltering.
Also change some formatting.
Diffstat (limited to 'src/tree')
-rw-r--r-- | src/tree/special_path.rs | 17 | ||||
-rw-r--r-- | src/tree/tree.rs | 5 | ||||
-rw-r--r-- | src/tree/tree_line.rs | 10 | ||||
-rw-r--r-- | src/tree/tree_line_type.rs | 10 | ||||
-rw-r--r-- | src/tree/tree_options.rs | 10 |
5 files changed, 26 insertions, 26 deletions
diff --git a/src/tree/special_path.rs b/src/tree/special_path.rs index 5a21e76..2ee8cf4 100644 --- a/src/tree/special_path.rs +++ b/src/tree/special_path.rs @@ -24,10 +24,7 @@ pub struct SpecialPath { } pub trait SpecialPathList { - fn find( - self, - path: &Path, - ) -> SpecialHandling; + fn find(self, path: &Path) -> SpecialHandling; } @@ -44,9 +41,10 @@ impl<'de> Deserialize<'de> for SpecialHandling { "enter" => Ok(SpecialHandling::Enter), "noenter" => Ok(SpecialHandling::NoEnter), "hide" => Ok(SpecialHandling::Hide), - _ => Err(D::Error::custom( - format!("unrecognized special handling: {:?}", s) - )), + _ => Err(D::Error::custom(format!( + "unrecognized special handling: {:?}", + s + ))), } } @@ -74,10 +72,7 @@ impl SpecialPath { } impl SpecialPathList for &[SpecialPath] { - fn find( - self, - path: &Path, - ) -> SpecialHandling { + fn find(self, path: &Path) -> SpecialHandling { for sp in self { if sp.pattern.matches_path(path) { return sp.handling; diff --git a/src/tree/tree.rs b/src/tree/tree.rs index 977d6ad..97144fc 100644 --- a/src/tree/tree.rs +++ b/src/tree/tree.rs @@ -355,7 +355,7 @@ impl Tree { TreeLineType::Dir | TreeLineType::Pruning => {} _ => { self.lines[i].sum = Some(FileSum::from_file(&self.lines[i].path)); - }, + } } } self.sort_siblings(); @@ -413,8 +413,7 @@ impl Tree { }); self.try_select_path(&selected_path); } - Sort::None => { - } + Sort::None => {} } } diff --git a/src/tree/tree_line.rs b/src/tree/tree_line.rs index 6b83666..8cf48ea 100644 --- a/src/tree/tree_line.rs +++ b/src/tree/tree_line.rs @@ -68,7 +68,7 @@ impl TreeLine { } pub fn double_extension_from_name(name: &str) -> Option<&str> { - regex!( r"\.([^.]+\.[^.]+)" ) + regex!(r"\.([^.]+\.[^.]+)") .captures(&name) .and_then(|c| c.get(1)) .map(|e| e.as_str()) @@ -87,7 +87,7 @@ impl TreeLine { pub fn is_dir(&self) -> bool { match &self.line_type { TreeLineType::Dir => true, - TreeLineType::SymLink { final_is_dir, ..} if *final_is_dir => true, + TreeLineType::SymLink { final_is_dir, .. } if *final_is_dir => true, _ => false, } } @@ -102,7 +102,7 @@ impl TreeLine { } } pub fn extension(&self) -> Option<&str> { - Self::extension_from_name( &self.name ) + Self::extension_from_name(&self.name) } pub fn selection_type(&self) -> SelectionType { use TreeLineType::*; @@ -136,7 +136,9 @@ impl TreeLine { use crate::filesystems::*; let mut mount_list = MOUNTS.lock().unwrap(); if mount_list.load().is_ok() { - mount_list.get_by_device_id(self.metadata.dev().into()).cloned() + mount_list + .get_by_device_id(self.metadata.dev().into()) + .cloned() } else { None } diff --git a/src/tree/tree_line_type.rs b/src/tree/tree_line_type.rs index 0dc5ad5..ed6d80b 100644 --- a/src/tree/tree_line_type.rs +++ b/src/tree/tree_line_type.rs @@ -22,7 +22,7 @@ pub enum TreeLineType { final_is_dir: bool, final_target: PathBuf, }, - Pruning, // a "xxx unlisted" line + Pruning, // a "xxx unlisted" line } pub fn read_link(path: &Path) -> io::Result<PathBuf> { @@ -50,7 +50,9 @@ impl TreeLineType { direct_target.display(), final_target.display(), ); - return Ok(Self::BrokenSymLink(direct_target.to_string_lossy().into_owned())) + return Ok(Self::BrokenSymLink( + direct_target.to_string_lossy().into_owned(), + )); } visited.insert(final_target.clone()); final_metadata = fs::symlink_metadata(&final_target)?; @@ -59,7 +61,9 @@ impl TreeLineType { link_chain_length += 1; if link_chain_length > MAX_LINK_CHAIN_LENGTH { info!("too long link chain at {}", direct_target.display()); - return Ok(Self::BrokenSymLink(direct_target.to_string_lossy().into_owned())) + return Ok(Self::BrokenSymLink( + direct_target.to_string_lossy().into_owned(), + )); } } let direct_target = direct_target.to_string_lossy().into_owned(); diff --git a/src/tree/tree_options.rs b/src/tree/tree_options.rs index 13a3ed8..16f75a0 100644 --- a/src/tree/tree_options.rs +++ b/src/tree/tree_options.rs @@ -9,16 +9,16 @@ use { pub struct TreeOptions { pub show_hidden: bool, // whether files whose name starts with a dot should be shown pub only_folders: bool, // whether to hide normal files and links - pub show_counts: bool, // whether to show the number of files (> 1 only for dirs) + pub show_counts: bool, // whether to show the number of files (> 1 only for dirs) pub show_dates: bool, // whether to show the last modified date pub show_sizes: bool, // whether to show sizes of files and dirs pub show_git_file_info: bool, pub show_root_fs: bool, // show information relative to the fs of the root - pub trim_root: bool, // whether to cut out direct children of root - pub show_permissions: bool, // show classic rwx unix permissions (only on unix) - pub respect_git_ignore: bool, // hide files as requested by .gitignore ? + pub trim_root: bool, // whether to cut out direct children of root + pub show_permissions: bool, // show classic rwx unix permissions (only on unix) + pub respect_git_ignore: bool, // hide files as requested by .gitignore ? pub filter_by_git_status: bool, // only show files whose git status is not nul - pub pattern: InputPattern, // an optional filtering/scoring pattern + pub pattern: InputPattern, // an optional filtering/scoring pattern pub date_time_format: &'static str, pub sort: Sort, } |