diff options
author | quentin konieczko <konieczko@gmail.com> | 2022-10-13 12:41:52 +0200 |
---|---|---|
committer | quentin konieczko <konieczko@gmail.com> | 2022-10-13 12:41:52 +0200 |
commit | 08da8ebde070187b1663e8a9a2e4312dfceefa7d (patch) | |
tree | 38383e6559651ea448cbeb564781821c850820b2 | |
parent | b6eeabe53c9d20ebb67d6bf7f6433806147a3c6c (diff) |
refactor, still display problem
-rw-r--r-- | src/actioner.rs | 5 | ||||
-rw-r--r-- | src/main.rs | 9 | ||||
-rw-r--r-- | src/skim.rs | 2 | ||||
-rw-r--r-- | src/tabs.rs | 13 |
4 files changed, 13 insertions, 16 deletions
diff --git a/src/actioner.rs b/src/actioner.rs index 336f662..e787e3c 100644 --- a/src/actioner.rs +++ b/src/actioner.rs @@ -178,9 +178,8 @@ impl Actioner { /// Insert a new tab in normal mode fn insert(&self, tabs: &mut Tabs) { - match tabs.selected().mode { - Mode::Normal => tabs.new_tab(), - _ => (), + if let Mode::Normal = tabs.selected().mode { + tabs.new_tab() } } diff --git a/src/main.rs b/src/main.rs index 58a32b9..ea355e7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,16 +6,15 @@ use tuikit::term::Term; use fm::actioner::Actioner; use fm::args::Args; use fm::config::load_config; -use fm::config::Colors; use fm::display::Display; use fm::tabs::Tabs; static CONFIG_PATH: &str = "~/.config/fm/config.yaml"; /// Returns a `Display` instance after `tuikit::term::Term` creation. -fn init_term(colors: Colors) -> Term { +fn init_term() -> Term { let term: Term<()> = Term::new().unwrap(); - let _ = term.enable_mouse_support().unwrap(); + let _ = term.enable_mouse_support(); term } @@ -29,7 +28,7 @@ fn reset_cursor(display: &Display) { /// The application is redrawn after every event. fn main() { let config = load_config(CONFIG_PATH); - let term = Arc::new(init_term(config.colors.clone())); + let term = Arc::new(init_term()); let actioner = Actioner::new(&config.keybindings, term.clone()); let mut display = Display::new(term, config.colors.clone()); let mut tabs = Tabs::new(Args::parse(), config, display.height()); @@ -42,7 +41,7 @@ fn main() { actioner.read_event(&mut tabs, event); - display.display_all(&mut tabs); + display.display_all(&tabs); let _ = display.term.present(); diff --git a/src/skim.rs b/src/skim.rs index 4249c71..22ff341 100644 --- a/src/skim.rs +++ b/src/skim.rs @@ -16,6 +16,6 @@ impl Skimer { skim.run_without(None) .map(|out| out.selected_items) - .unwrap_or_else(|| Vec::new()) + .unwrap_or_else(Vec::new) } } diff --git a/src/tabs.rs b/src/tabs.rs index 0569dcf..f8e9d40 100644 --- a/src/tabs.rs +++ b/src/tabs.rs @@ -1,8 +1,7 @@ use regex::Regex; use skim::SkimItem; -use std::borrow::Cow; use std::collections::HashSet; -use std::fs::{self, metadata}; +use std::fs; use std::os::unix::fs::PermissionsExt; use std::path::{self, PathBuf}; use std::sync::Arc; @@ -132,21 +131,21 @@ impl Tabs { pub fn create_tabs_from_skim(&mut self, output: Vec<Arc<dyn SkimItem>>) { for path in output.iter() { - self.create_tab_from_output(path) + self.create_tab_from_skim_output(path) } } - fn create_tab_from_output(&mut self, cow_path: &Arc<dyn SkimItem>) { + fn create_tab_from_skim_output(&mut self, cow_path: &Arc<dyn SkimItem>) { let mut status = self.selected().clone(); let s_path = cow_path.output().to_string(); if let Ok(path) = fs::canonicalize(path::Path::new(&s_path)) { - if metadata(path.clone()).unwrap().is_file() { + if path.is_file() { if let Some(parent) = path.parent() { status.set_pathcontent(parent.to_path_buf()); self.statuses.push(status); } - } else { - status.set_pathcontent(path.to_path_buf()); + } else if path.is_dir() { + status.set_pathcontent(path); self.statuses.push(status); } } |