diff --git a/src/builtins/history.rs b/src/builtins/history.rs index 76f00c71c..a69426b37 100644 --- a/src/builtins/history.rs +++ b/src/builtins/history.rs @@ -256,7 +256,7 @@ pub fn history(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> // from webconfig.py. let history = commandline_get_state(true) .history - .unwrap_or_else(|| History::with_name(&history_session_id(parser.vars()))); + .unwrap_or_else(|| History::new(&history_session_id(parser.vars()))); // If a history command hasn't already been specified via a flag check the first word. // Note that this can be simplified after we eliminate allowing subcommands as flags. diff --git a/src/builtins/set.rs b/src/builtins/set.rs index d6a4bd941..f518db6f4 100644 --- a/src/builtins/set.rs +++ b/src/builtins/set.rs @@ -567,7 +567,7 @@ fn list(opts: &Options, parser: &Parser, streams: &mut IoStreams) -> BuiltinResu if !names_only { let mut val = WString::new(); if opts.shorten_ok && key == "history" { - let history = History::with_name(&history_session_id(parser.vars())); + let history = History::new(&history_session_id(parser.vars())); for i in 1..history.size() { if val.len() >= 64 { break; diff --git a/src/complete.rs b/src/complete.rs index 751081989..87ad762b6 100644 --- a/src/complete.rs +++ b/src/complete.rs @@ -1675,7 +1675,7 @@ fn complete_variable(&mut self, s: &wstr, start_offset: usize) -> bool { // $history can be huge, don't put all of it in the completion description; see // #6288. if env_name == "history" { - let history = History::with_name(&history_session_id(self.ctx.vars())); + let history = History::new(&history_session_id(self.ctx.vars())); for i in 1..std::cmp::min(history.size(), 64) { if i > 1 { desc.push(' '); diff --git a/src/env/environment_impl.rs b/src/env/environment_impl.rs index 6e040e79a..d0635b0ac 100644 --- a/src/env/environment_impl.rs +++ b/src/env/environment_impl.rs @@ -374,7 +374,7 @@ fn try_get_computed(&self, key: &wstr) -> Option { let history = commandline_get_state(true).history.unwrap_or_else(|| { let fish_history_var = self.getf(L!("fish_history"), EnvMode::default()); let session_id = history_session_id_from_var(fish_history_var); - History::with_name(&session_id) + History::new(&session_id) }); Some(EnvVar::new_from_name_vec( L!("history"), diff --git a/src/expand.rs b/src/expand.rs index 490fc5944..7f7c9e7e7 100644 --- a/src/expand.rs +++ b/src/expand.rs @@ -613,7 +613,7 @@ fn expand_variables( let mut history = None; let mut var = None; if var_name == "history" { - history = Some(History::with_name(&history_session_id(vars))); + history = Some(History::new(&history_session_id(vars))); } else if var_name.as_char_slice() != [VARIABLE_EXPAND_EMPTY] { var = vars.get(var_name); } diff --git a/src/history/history.rs b/src/history/history.rs index 74068b86b..b2f8e4f9a 100644 --- a/src/history/history.rs +++ b/src/history/history.rs @@ -1218,7 +1218,7 @@ pub fn add_commandline(&self, s: WString) { /// Creates a new History with a custom directory path. /// The history file will be stored at `{directory}/{name}_history`. /// If the directory is None, it will be stored at path_get_data(). - fn new(name: &wstr, directory: Option) -> Arc { + fn new_with_directory(name: &wstr, directory: Option) -> Arc { Arc::new(Self(Mutex::new(HistoryImpl::new( name.to_owned(), directory, @@ -1228,13 +1228,13 @@ fn new(name: &wstr, directory: Option) -> Arc { /// Returns the history with the given name, creating it if necessary, using the default data directory. /// This uses the HISTORIES global collection. Note it is possible to create a history without /// placing it into this collection. - pub fn with_name(name: &wstr) -> Arc { + pub fn new(name: &wstr) -> Arc { let mut histories = HISTORIES.lock().unwrap(); if let Some(hist) = histories.get(name) { Arc::clone(hist) } else { - let hist = Self::new(name, None); + let hist = Self::new_with_directory(name, None); histories.insert(name.to_owned(), Arc::clone(&hist)); hist } @@ -1834,7 +1834,7 @@ fn history_contains(history: &History, txt: &wstr) -> bool { // Helper to create a history with a custom directory, for testing. fn create_test_history(name: &wstr, custom_dir: &wstr) -> Arc { - History::new(name, Some(custom_dir.to_owned())) + History::new_with_directory(name, Some(custom_dir.to_owned())) } fn random_string(rng: &mut ThreadRng) -> WString { @@ -2309,7 +2309,7 @@ fn test_history_path_detection() { test_vars.set_one(L!("PWD"), global_mode, wdir_path.clone()); test_vars.set_one(L!("HOME"), global_mode, wdir_path.clone()); - let history = History::new(L!("path_detection"), hist_dir); + let history = History::new_with_directory(L!("path_detection"), hist_dir); history.clear(); assert_eq!(history.size(), 0); history.add_pending_with_file_detection( diff --git a/src/reader/reader.rs b/src/reader/reader.rs index 50b92de2b..f4503cad5 100644 --- a/src/reader/reader.rs +++ b/src/reader/reader.rs @@ -398,7 +398,7 @@ pub fn reader_push<'a>(parser: &'a Parser, history_name: &wstr, conf: ReaderConf } else { InputData::new(inputfd, *parser.blocking_query_timeout.borrow()) }; - let hist = History::with_name(history_name); + let hist = History::new(history_name); hist.resolve_pending(); let data = ReaderData::new(input_data, hist, conf, reader_data_stack().is_empty()); reader_data_stack().push(data); @@ -427,7 +427,7 @@ pub fn fake_scoped_reader<'a>(parser: &'a Parser) -> impl ScopeGuarding