From 41571dec0f26e3944af89f94e462401a1f2338df Mon Sep 17 00:00:00 2001 From: Peter Ammon Date: Tue, 23 Dec 2025 08:33:29 -0800 Subject: [PATCH] Minor simplification of history --- src/history/history.rs | 23 ++++++++++++----------- src/reader/reader.rs | 7 ++----- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/history/history.rs b/src/history/history.rs index 77ee0b8e2..3bb8d1120 100644 --- a/src/history/history.rs +++ b/src/history/history.rs @@ -1256,7 +1256,7 @@ pub fn remove_ephemeral_items(&self) { /// determine which arguments are paths. Arguments may be expanded (e.g. with PWD and variables) /// using the given `vars`. The item has the given `persist_mode`. pub fn add_pending_with_file_detection( - self: Arc, + self: &Arc, s: &wstr, vars: &EnvStack, persist_mode: PersistenceMode, /*=disk*/ @@ -1318,10 +1318,11 @@ pub fn add_pending_with_file_detection( let thread_pool = Arc::clone(&imp.thread_pool); drop(imp); let vars_snapshot = vars.snapshot(); + let self_clone = Arc::clone(self); thread_pool.perform(move || { // Don't hold the lock while we perform this file detection. let valid_file_paths = expand_and_detect_paths(potential_paths, &vars_snapshot); - let mut imp = self.imp(); + let mut imp = self_clone.imp(); if !valid_file_paths.is_empty() { imp.set_valid_file_paths(valid_file_paths, &snapshot_item); } @@ -2275,47 +2276,47 @@ fn test_history_path_detection() { let history = History::with_name(L!("path_detection")); history.clear(); assert_eq!(history.size(), 0); - history.clone().add_pending_with_file_detection( + history.add_pending_with_file_detection( L!("cmd0 not/a/valid/path"), &test_vars, PersistenceMode::Disk, ); - history.clone().add_pending_with_file_detection( + history.add_pending_with_file_detection( &(L!("cmd1 ").to_owned() + filename), &test_vars, PersistenceMode::Disk, ); - history.clone().add_pending_with_file_detection( + history.add_pending_with_file_detection( &(L!("cmd2 ").to_owned() + &wfile_path[..]), &test_vars, PersistenceMode::Disk, ); - history.clone().add_pending_with_file_detection( + history.add_pending_with_file_detection( &(L!("cmd3 $HOME/").to_owned() + filename), &test_vars, PersistenceMode::Disk, ); - history.clone().add_pending_with_file_detection( + history.add_pending_with_file_detection( L!("cmd4 $HOME/notafile"), &test_vars, PersistenceMode::Disk, ); - history.clone().add_pending_with_file_detection( + history.add_pending_with_file_detection( &(L!("cmd5 ~/").to_owned() + filename), &test_vars, PersistenceMode::Disk, ); - history.clone().add_pending_with_file_detection( + history.add_pending_with_file_detection( L!("cmd6 ~/notafile"), &test_vars, PersistenceMode::Disk, ); - history.clone().add_pending_with_file_detection( + history.add_pending_with_file_detection( L!("cmd7 ~/*f*"), &test_vars, PersistenceMode::Disk, ); - history.clone().add_pending_with_file_detection( + history.add_pending_with_file_detection( L!("cmd8 ~/*zzz*"), &test_vars, PersistenceMode::Disk, diff --git a/src/reader/reader.rs b/src/reader/reader.rs index 9e84ad932..37fb1e7c7 100644 --- a/src/reader/reader.rs +++ b/src/reader/reader.rs @@ -6113,11 +6113,8 @@ fn add_to_history(&mut self) { } else { PersistenceMode::Disk }; - self.history.clone().add_pending_with_file_detection( - &text, - &self.parser.variables, - mode, - ); + self.history + .add_pending_with_file_detection(&text, &self.parser.variables, mode); } }