diff options
author | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2020-03-18 22:55:09 -0400 |
---|---|---|
committer | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2020-03-18 22:55:09 -0400 |
commit | 06b2d7730d10240b471e859c7988ed219aa4c590 (patch) | |
tree | f5dcca189bb2d79c4def09540eec73cdb832c6b8 | |
parent | f3081669e488c54ab4fcae2829ea2f58f082c6e7 (diff) |
remove cursormovestub and add rudimentary sort command
-rw-r--r-- | src/commands/cursor_move.rs | 36 | ||||
-rw-r--r-- | src/commands/delete_files.rs | 6 | ||||
-rw-r--r-- | src/commands/file_ops/paste_copy.rs | 7 | ||||
-rw-r--r-- | src/commands/file_ops/paste_cut.rs | 7 | ||||
-rw-r--r-- | src/commands/mod.rs | 23 | ||||
-rw-r--r-- | src/commands/reload_dir.rs | 5 | ||||
-rw-r--r-- | src/commands/rename_file.rs | 5 | ||||
-rw-r--r-- | src/commands/sort.rs | 39 | ||||
-rw-r--r-- | src/commands/tab_operations.rs | 5 | ||||
-rw-r--r-- | src/config/keymap.rs | 99 | ||||
-rw-r--r-- | src/history.rs | 29 | ||||
-rw-r--r-- | src/main.rs | 2 | ||||
-rw-r--r-- | src/run.rs | 20 | ||||
-rw-r--r-- | src/sort.rs | 2 | ||||
-rw-r--r-- | src/ui/widgets/tui_view.rs | 3 | ||||
-rw-r--r-- | src/util/load_child.rs | 2 |
16 files changed, 169 insertions, 121 deletions
diff --git a/src/commands/cursor_move.rs b/src/commands/cursor_move.rs index ba536bb..a19c264 100644 --- a/src/commands/cursor_move.rs +++ b/src/commands/cursor_move.rs @@ -30,46 +30,12 @@ pub fn cursor_move(new_index: usize, context: &mut JoshutoContext) { if path.is_dir() { curr_tab .history - .create_or_update(path.as_path(), &context.config_t.sort_option); + .create_or_soft_update(path.as_path(), &context.config_t.sort_option); } } } #[derive(Clone, Debug)] -pub struct CursorMoveStub {} - -impl CursorMoveStub { - pub fn new() -> Self { - Self {} - } - pub const fn command() -> &'static str { - "cursor_move_stub" - } -} - -impl JoshutoCommand for CursorMoveStub {} - -impl std::fmt::Display for CursorMoveStub { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - write!(f, "{}", Self::command()) - } -} - -impl JoshutoRunnable for CursorMoveStub { - fn execute(&self, context: &mut JoshutoContext, _: &mut TuiBackend) -> JoshutoResult<()> { - let new_index = match context.curr_tab_ref().curr_list_ref() { - Some(curr_list) => curr_list.index, - None => None, - }; - - if let Some(s) = new_index { - cursor_move(s, context) - } - Ok(()) - } -} - -#[derive(Clone, Debug)] pub struct CursorMoveDown { movement: usize, } diff --git a/src/commands/delete_files.rs b/src/commands/delete_files.rs index 9e302b0..628f324 100644 --- a/src/commands/delete_files.rs +++ b/src/commands/delete_files.rs @@ -3,12 +3,12 @@ use std::path; use termion::event::Key; -use crate::commands::{CursorMoveStub, JoshutoCommand, JoshutoRunnable, ReloadDirList}; +use crate::commands::{JoshutoCommand, JoshutoRunnable, ReloadDirList}; use crate::context::JoshutoContext; use crate::error::JoshutoResult; use crate::ui::TuiBackend; - use crate::ui::widgets::TuiPrompt; +use crate::util::load_child::LoadChild; #[derive(Clone, Debug)] pub struct DeleteFiles; @@ -90,7 +90,7 @@ impl std::fmt::Display for DeleteFiles { impl JoshutoRunnable for DeleteFiles { fn execute(&self, context: &mut JoshutoContext, backend: &mut TuiBackend) -> JoshutoResult<()> { Self::delete_files(context, backend)?; - CursorMoveStub::new().execute(context, backend)?; + LoadChild::load_child(context)?; Ok(()) } } diff --git a/src/commands/file_ops/paste_copy.rs b/src/commands/file_ops/paste_copy.rs index b3234bf..46bafbc 100644 --- a/src/commands/file_ops/paste_copy.rs +++ b/src/commands/file_ops/paste_copy.rs @@ -50,8 +50,8 @@ pub fn paste_copy( let (tx_start, rx_start) = mpsc::channel(); let (tx, rx) = mpsc::channel(); - let handle: thread::JoinHandle<std::io::Result<u64>> = thread::spawn(move || { - match rx_start.recv() { + let handle: thread::JoinHandle<std::io::Result<u64>> = + thread::spawn(move || match rx_start.recv() { Ok(_) => { let mut total = 0; for path in paths { @@ -61,8 +61,7 @@ pub fn paste_copy( Ok(total) } Err(_) => Ok(0), - } - }); + }); let thread = IOWorkerThread { src, diff --git a/src/commands/file_ops/paste_cut.rs b/src/commands/file_ops/paste_cut.rs index 5b6683b..4fa171d 100644 --- a/src/commands/file_ops/paste_cut.rs +++ b/src/commands/file_ops/paste_cut.rs @@ -64,8 +64,8 @@ pub fn paste_cut( let (tx_start, rx_start) = mpsc::channel(); let (tx, rx) = mpsc::channel(); - let handle: thread::JoinHandle<std::io::Result<u64>> = thread::spawn(move || { - match rx_start.recv() { + let handle: thread::JoinHandle<std::io::Result<u64>> = + thread::spawn(move || match rx_start.recv() { Ok(_) => { let mut total = 0; for path in paths { @@ -75,8 +75,7 @@ pub fn paste_cut( Ok(total) } Err(_) => Ok(0), - } - }); + }); let thread = IOWorkerThread { src, diff --git a/src/commands/mod.rs b/src/commands/mod.rs index d511a52..b322d49 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -14,6 +14,7 @@ mod search; mod selection; mod set_mode; mod show_hidden; +mod sort; mod tab_operations; mod tab_switch; @@ -22,7 +23,7 @@ pub use self::change_directory::ChangeDirectory; pub use self::command_line::CommandLine; pub use self::cursor_move::{ CursorMoveDown, CursorMoveEnd, CursorMoveHome, CursorMovePageDown, CursorMovePageUp, - CursorMoveStub, CursorMoveUp, + CursorMoveUp, }; pub use self::delete_files::DeleteFiles; pub use self::file_ops::{CopyFiles, CutFiles, PasteFiles}; @@ -37,6 +38,7 @@ pub use self::search::{Search, SearchNext, SearchPrev}; pub use self::selection::SelectFiles; pub use self::set_mode::SetMode; pub use self::show_hidden::ToggleHiddenFiles; +pub use self::sort::Sort; pub use self::tab_operations::{CloseTab, NewTab}; pub use self::tab_switch::TabSwitch; @@ -46,6 +48,7 @@ use crate::config::JoshutoCommandMapping; use crate::context::JoshutoContext; use crate::error::{JoshutoError, JoshutoErrorKind, JoshutoResult}; use crate::io::Options; +use crate::sort::SortType; use crate::ui::TuiBackend; use crate::HOME_DIR; @@ -214,6 +217,24 @@ pub fn from_args(command: String, args: Vec<String>) -> JoshutoResult<Box<dyn Jo Ok(Box::new(self::SelectFiles::new(toggle, all))) } "set_mode" => Ok(Box::new(self::SetMode::new())), + "sort" => { + if args.len() == 1 { + match args[0].as_str() { + "lexical" => Ok(Box::new(self::Sort::new(SortType::Lexical))), + "mtime" => Ok(Box::new(self::Sort::new(SortType::Mtime))), + "natural" => Ok(Box::new(self::Sort::new(SortType::Natural))), + a => Err(JoshutoError::new( + JoshutoErrorKind::IOInvalidData, + format!("sort: Unknown option {}", a), + )), + } + } else { + Err(JoshutoError::new( + JoshutoErrorKind::IOInvalidData, + format!("sort: Expected 1, got {}", args.len()), + )) + } + } "tab_switch" => { if args.len() == 1 { match args[0].parse::<i32>() { diff --git a/src/commands/reload_dir.rs b/src/commands/reload_dir.rs index 2951e9f..a5ef752 100644 --- a/src/commands/reload_dir.rs +++ b/src/commands/reload_dir.rs @@ -1,7 +1,8 @@ -use crate::commands::{CursorMoveStub, JoshutoCommand, JoshutoRunnable}; +use crate::commands::{JoshutoCommand, JoshutoRunnable}; use crate::context::JoshutoContext; use crate::error::JoshutoResult; use crate::ui::TuiBackend; +use crate::util::load_child::LoadChild; #[derive(Clone, Debug)] pub struct ReloadDirList; @@ -43,7 +44,7 @@ impl std::fmt::Display for ReloadDirList { impl JoshutoRunnable for ReloadDirList { fn execute(&self, context: &mut JoshutoContext, backend: &mut TuiBackend) -> JoshutoResult<()> { Self::reload(context.curr_tab_index, context)?; - CursorMoveStub::new().execute(context, backend)?; + LoadChild::load_child(context)?; Ok(()) } } diff --git a/src/commands/rename_file.rs b/src/commands/rename_file.rs index 0bab5e6..a36c86c 100644 --- a/src/commands/rename_file.rs +++ b/src/commands/rename_file.rs @@ -1,9 +1,10 @@ use std::path; -use crate::commands::{CommandLine, CursorMoveStub, JoshutoCommand, JoshutoRunnable}; +use crate::commands::{CommandLine, JoshutoCommand, JoshutoRunnable}; use crate::context::JoshutoContext; use crate::error::JoshutoResult; use crate::ui::TuiBackend; +use crate::util::load_child::LoadChild; #[derive(Clone, Debug)] pub struct RenameFile { @@ -59,7 +60,7 @@ impl JoshutoRunnable for RenameFile { if let Some(path) = path { self.rename_file(&path, context)?; } - CursorMoveStub::new().execute(context, backend)?; + LoadChild::load_child(context)?; Ok(()) } } diff --git a/src/commands/sort.rs b/src/commands/sort.rs new file mode 100644 index 0000000..935e7fd --- /dev/null +++ b/src/commands/sort.rs @@ -0,0 +1,39 @@ +use std::path; + +use crate::commands::{JoshutoCommand, JoshutoRunnable}; +use crate::context::JoshutoContext; +use crate::error::JoshutoResult; +use crate::ui::TuiBackend; + +use crate::sort::SortType; + +use crate::HOME_DIR; + +#[derive(Clone, Debug)] +pub struct Sort { + sort_method: SortType, +} + +impl Sort { + pub fn new(sort_method: SortType) -> Self { + Self { sort_method } + } + pub const fn command() -> &'static str { + "sort" + } +} + +impl JoshutoCommand for Sort {} + +impl std::fmt::Display for Sort { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(Self::command()) + } +} + +impl JoshutoRunnable for Sort { + fn execute(&self, context: &mut JoshutoContext, backend: &mut TuiBackend) -> JoshutoResult<()> { + context.config_t.sort_option.sort_method = self.sort_method; + Ok(()) + } +} diff --git a/src/commands/tab_operations.rs b/src/commands/tab_operations.rs index 6c62d09..52c03ef 100644 --- a/src/commands/tab_operations.rs +++ b/src/commands/tab_operations.rs @@ -1,10 +1,11 @@ use std::path; -use crate::commands::{CursorMoveStub, JoshutoCommand, JoshutoRunnable, Quit, TabSwitch}; +use crate::commands::{JoshutoCommand, JoshutoRunnable, Quit, TabSwitch}; use crate::context::JoshutoContext; use crate::error::JoshutoResult; use crate::tab::JoshutoTab; use crate::ui::TuiBackend; +use crate::util::load_child::LoadChild; use crate::HOME_DIR; @@ -30,7 +31,7 @@ impl NewTab { context.tabs.push(tab); context.curr_tab_index = context.tabs.len() - 1; TabSwitch::tab_switch(context.curr_tab_index, context)?; - CursorMoveStub::new().execute(context, backend)?; + LoadChild::load_child(context)?; Ok(()) } } diff --git a/src/config/keymap.rs b/src/config/keymap.rs index 2ff5e43..c1199e8 100644 --- a/src/config/keymap.rs +++ b/src/config/keymap.rs @@ -42,167 +42,163 @@ impl std::default::Default for JoshutoCommandMapping { }; let cmd = Box::new(commands::CursorMoveUp::new(1)); - let keys = [ Key::Up ]; + let keys = [Key::Up]; insert_keycommand(&mut m, cmd, &keys); let cmd = Box::new(commands::CursorMoveDown::new(1)); - let keys = [ Key::Down ]; + let keys = [Key::Down]; insert_keycommand(&mut m, cmd, &keys); let cmd = Box::new(commands::ParentDirectory::new()); - let keys = [ Key::Left ]; + let keys = [Key::Left]; insert_keycommand(&mut m, cmd, &keys); let cmd = Box::new(commands::OpenFile::new()); - let keys = [ Key::Right ]; + let keys = [Key::Right]; insert_keycommand(&mut m, cmd, &keys); let cmd = Box::new(commands::OpenFile::new()); - let keys = [ Key::Char('\n') ]; + let keys = [Key::Char('\n')]; insert_keycommand(&mut m, cmd, &keys); let cmd = Box::new(commands::CursorMoveHome::new()); - let keys = [ Key::Home ]; + let keys = [Key::Home]; insert_keycommand(&mut m, cmd, &keys); let cmd = Box::new(commands::CursorMoveEnd::new()); - let keys = [ Key::End ]; + let keys = [Key::End]; insert_keycommand(&mut m, cmd, &keys); let cmd = Box::new(commands::CursorMovePageUp::new()); - let keys = [ Key::PageUp ]; + let keys = [Key::PageUp]; insert_keycommand(&mut m, cmd, &keys); let cmd = Box::new(commands::CursorMovePageDown::new()); - let keys = [ Key::PageDown ]; + let keys = [Key::PageDown]; insert_keycommand(&mut m, cmd, &keys); // vim keys let cmd = Box::new(commands::CursorMoveUp::new(1)); - let keys = [ Key::Char('k') ]; + let keys = [Key::Char('k')]; insert_keycommand(&mut m, cmd, &keys); let cmd = Box::new(commands::CursorMoveDown::new(1)); - let keys = [ Key::Char('j') ]; + let keys = [Key::Char('j')]; insert_keycommand(&mut m, cmd, &keys); let cmd = Box::new(commands::ParentDirectory::new()); - let keys = [ Key::Char('h') ]; + let keys = [Key::Char('h')]; insert_keycommand(&mut m, cmd, &keys); let cmd = Box::new(commands::OpenFile::new()); - let keys = [ Key::Char('l') ]; + let keys = [Key::Char('l')]; insert_keycommand(&mut m, cmd, &keys); let cmd = Box::new(commands::NewTab::new()); - let keys = [ Key::Char('T') ]; + let keys = [Key::Char('T')]; insert_keycommand(&mut m, cmd, &keys); let cmd = Box::new(commands::NewTab::new()); - let keys = [ Key::Ctrl('t') ]; + let keys = [Key::Ctrl('t')]; insert_keycommand(&mut m, cmd, &keys); let cmd = Box::new(commands::NewTab::new()); - let keys = [ Key::Char('W') ]; + let keys = [Key::Char('W')]; insert_keycommand(&mut m, cmd, &keys); let cmd = Box::new(commands::NewTab::new()); - let keys = [ Key::Ctrl('w') ]; + let keys = [Key::Ctrl('w')]; insert_keycommand(&mut m, cmd, &keys); let cmd = Box::new(commands::CloseTab::new()); - let keys = [ Key::Char('q') ]; + let keys = [Key::Char('q')]; insert_keycommand(&mut m, cmd, &keys); let cmd = Box::new(commands::ForceQuit::new()); - let keys = [ Key::Char('Q') ]; + let keys = [Key::Char('Q')]; insert_keycommand(&mut m, cmd, &keys); let cmd = Box::new(commands::ReloadDirList::new()); - let keys = [ Key::Char('R') ]; + let keys = [Key::Char('R')]; insert_keycommand(&mut m, cmd, &keys); - let cmd = Box::new(commands::ToggleHiddenFiles::new()); - let keys = [ Key::Char('z'), Key::Char('h') ]; + let keys = [Key::Char('z'), Key::Char('h')]; insert_keycommand(&mut m, cmd, &keys); let cmd = Box::new(commands::TabSwitch::new(1)); - let keys = [ Key::Char('\t') ]; + let keys = [Key::Char('\t')]; insert_keycommand(&mut m, cmd, &keys); let cmd = Box::new(commands::TabSwitch::new(-1)); - let keys = [ Key::BackTab ]; + let keys = [Key::BackTab]; insert_keycommand(&mut m, cmd, &keys); let cmd = Box::new(commands::OpenFileWith::new()); - let keys = [ Key::Char('r') ]; + let keys = [Key::Char('r')]; insert_keycommand(&mut m, cmd, &keys); let cmd = Box::new(commands::CutFiles::new()); - let keys = [ Key::Char('d'), Key::Char('d') ]; + let keys = [Key::Char('d'), Key::Char('d')]; insert_keycommand(&mut m, cmd, &keys); let cmd = Box::new(commands::CopyFiles::new()); - let keys = [ Key::Char('y'), Key::Char('y') ]; + let keys = [Key::Char('y'), Key::Char('y')]; insert_keycommand(&mut m, cmd, &keys); let cmd = Box::new(commands::PasteFiles::new(Options::default())); - let keys = [ Key::Char('p'), Key::Char('p') ]; + let keys = [Key::Char('p'), Key::Char('p')]; insert_keycommand(&mut m, cmd, &keys); let cmd = Box::new(commands::DeleteFiles::new()); - let keys = [ Key::Delete ]; + let keys = [Key::Delete]; insert_keycommand(&mut m, cmd, &keys); let cmd = Box::new(commands::DeleteFiles::new()); - let keys = [ Key::Char('D'), Key::Char('d') ]; + let keys = [Key::Char('D'), Key::Char('d')]; insert_keycommand(&mut m, cmd, &keys); let cmd = Box::new(commands::RenameFileAppend::new()); - let keys = [ Key::Char('a') ]; + let keys = [Key::Char('a')]; insert_keycommand(&mut m, cmd, &keys); let cmd = Box::new(commands::RenameFilePrepend::new()); - let keys = [ Key::Char('A') ]; + let keys = [Key::Char('A')]; insert_keycommand(&mut m, cmd, &keys); let cmd = Box::new(commands::CommandLine::new( "search ".to_string(), "".to_string(), )); - let keys = [ Key::Char('/') ]; + let keys = [Key::Char('/')]; insert_keycommand(&mut m, cmd, &keys); let cmd = Box::new(commands::SearchNext::new()); - let keys = [ Key::Char('n') ]; + let keys = [Key::Char('n')]; insert_keycommand(&mut m, cmd, &keys); let cmd = Box::new(commands::SearchPrev::new()); - let keys = [ Key::Char('N') ]; + let keys = [Key::Char('N')]; insert_keycommand(&mut m, cmd, &keys); let cmd = Box::new(commands::BulkRename::new()); - let keys = [ Key::Char('b'), Key::Char('b') ]; + let keys = [Key::Char('b'), Key::Char('b')]; insert_keycommand(&mut m, cmd, &keys); let cmd = Box::new(commands::SetMode::new()); - let keys = [ Key::Char('=') ]; + let keys = [Key::Char('=')]; insert_keycommand(&mut m, cmd, &keys); - let cmd = Box::new(commands::CommandLine::new( - "".to_string(), - "".to_string(), - )); - let keys = [ Key::Char(';') ]; + let cmd = Box::new(commands::CommandLine::new("".to_string(), "".to_string())); + let keys = [Key::Char(';')]; insert_keycommand(&mut m, cmd, &keys); let cmd = Box::new(commands::CommandLine::new( - "mkdir ".to_string(), - "".to_string(), - )); - let keys = [ Key::Char('m'), Key::Char('k') ]; + "mkdir ".to_string(), + "".to_string(), + )); + let keys = [Key::Char('m'), Key::Char('k')]; insert_keycommand(&mut m, cmd, &keys); let cmd = Box::new(commands::CommandLine::new( - "rename ".to_string(), - "".to_string(), - )); - let keys = [ Key::Char('c'), Key::Char('w') ]; + "rename ".to_string(), + "".to_string(), + )); + let keys = [Key::Char('c'), Key::Char('w')]; insert_keycommand(&mut m, cmd, &keys); m @@ -236,7 +232,8 @@ impl Flattenable<JoshutoCommandMapping> for JoshutoRawCommandMapping { for m in self.mapcommand { match commands::from_args(m.command, m.args) { Ok(command) => { - let keycodes: Vec<Key> = m.keys + let keycodes: Vec<Key> = m + .keys .iter() .filter_map(|s| str_to_key(s.as_str())) .collect(); diff --git a/src/history.rs b/src/history.rs index 16fc8a3..6068b13 100644 --- a/src/history.rs +++ b/src/history.rs @@ -10,7 +10,12 @@ pub trait DirectoryHistory { path: &Path, sort_option: &sort::SortOption, ) -> std::io::Result<()>; - fn create_or_update( + fn create_or_soft_update( + &mut self, + path: &Path, + sort_option: &sort::SortOption, + ) -> std::io::Result<()>; + fn create_or_reload( &mut self, path: &Path, sort_option: &sort::SortOption, @@ -56,7 +61,27 @@ impl DirectoryHistory for JoshutoHistory { Ok(()) } - fn create_or_update( + fn create_or_soft_update( + &mut self, + path: &Path, + sort_option: &sort::SortOption, + ) -> std::io::Result<()> { + match self.entry(path.to_path_buf()) { + Entry::Occupied(mut entry) => { + let dirlist = entry.get_mut(); + if dirlist.need_update() { + dirlist.reload_contents(sort_option)?; + } + } + Entry::Vacant(entry) => { + let dirlist = JoshutoDirList::new(path.to_path_buf(), sort_option)?; + entry.insert(dirlist); + } + } + Ok(()) + } + + fn create_or_reload( &mut self, path: &Path, sort_option: &sort::SortOption, diff --git a/src/main.rs b/src/main.rs index 5820b1f..d783a9e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -70,7 +70,7 @@ fn main() { } if let Some(p) = args.path { match std::env::set_current_dir(p.as_path()) { - Ok(_) => {}, + Ok(_) => {} Err(e) => { eprintln!("{}", e); process::exit(1); @@ -1,4 +1,4 @@ -use crate::commands::{CommandKeybind, CursorMoveStub, JoshutoRunnable}; +use crate::commands::{CommandKeybind, JoshutoRunnable}; use crate::config::{JoshutoCommandMapping, JoshutoConfig}; use crate::context::JoshutoContext; use crate::history::DirectoryHistory; @@ -7,6 +7,7 @@ use crate::tab::JoshutoTab; use crate::ui; use crate::ui::widgets::{TuiCommandMenu, TuiView}; use crate::util::event::Event; +use crate::util::load_child::LoadChild; pub fn run(config_t: JoshutoConfig, keymap_t: JoshutoCommandMapping) -> std::io::Result<()> { let mut backend: ui::TuiBackend = ui::TuiBackend::new()?; @@ -19,8 +20,8 @@ pub fn run(config_t: JoshutoConfig, keymap_t: JoshutoCommandMapping) -> std::io: let tab = JoshutoTab::new(curr_path, &context.config_t.sort_option)?; context.push_tab(tab); - // move the cursor by 0 just to trigger a preview of child - CursorMoveStub::new().execute(&mut context, &mut backend); + // trigger a preview of child + LoadChild::load_child(&mut context)?; // render our view let mut view = TuiView::new(&context); @@ -57,19 +58,18 @@ pub fn run(config_t: JoshutoConfig, keymap_t: JoshutoCommandMapping) -> std::io: let dest = handle.dest.clone(); handle.join(); let msg = match res { - Ok(s) => { - format!("io_worker completed successfully: {:.3} KB processed", - s as f64 / 1024.0) - } + Ok(s) => format!( + "io_worker completed successfully: {:.3} KB processed", + s as f64 / 1024.0 + ), Err(e) => format!("io_worker was not completed: {}", e.to_string()), }; context.message_queue.push_back(msg); let options = &context.config_t.sort_option; for tab in context.tabs.iter_mut() { - tab.history.create_or_update(src.as_path(), options); - tab.history.create_or_update(dest.as_path(), options); + tab.history.depreciate_all_entries(); } - CursorMoveStub::new().execute(&mut context, &mut backend); + LoadChild::load_child(&mut context)?; } None => {} } diff --git a/src/sort.rs b/src/sort.rs index 5bb6112..a40d6dc 100644 --- a/src/sort.rs +++ b/src/sort.rs @@ -7,7 +7,7 @@ use crate::fs::JoshutoDirEntry; use alphanumeric_sort::compare_str; use serde_derive::Deserialize; -#[derive(Clone, Debug, Deserialize)] +#[derive(Clone, Copy, Debug, Deserialize)] pub enum SortType { Lexical, Mtime, diff --git a/src/ui/widgets/tui_view.rs b/src/ui/widgets/tui_view.rs index 3cc630d..72ff38c 100644 --- a/src/ui/widgets/tui_view.rs +++ b/src/ui/widgets/tui_view.rs @@ -101,8 +101,7 @@ impl<'a> Widget for TuiView<'a> { height: 1, }; - let message_style = Style::default() - .fg(Color::Yellow); + let message_style = Style::default().fg(Color::Yellow); if self.show_bottom_status { /* draw the bottom status bar */ diff --git a/src/util/load_child.rs b/src/util/load_child.rs index 78872b8..1328eb5 100644 --- a/src/util/load_child.rs +++ b/src/util/load_child.rs @@ -22,7 +22,7 @@ impl LoadChild { if path.is_dir() { curr_tab .history - .create_or_update(path.as_path(), &context.config_t.sort_option)?; + .create_or_soft_update(path.as_path(), &context.config_t.sort_option)?; } } Ok(()) |