mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-01-22 13:34:59 +08:00
Thread variables into autoload_names
Stop fetching a global set of variables.
This commit is contained in:
parent
d2d2d8cb45
commit
7fcbe5b8ab
|
@ -275,7 +275,7 @@ pub fn functions(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -
|
||||||
}
|
}
|
||||||
|
|
||||||
if opts.list || args.is_empty() {
|
if opts.list || args.is_empty() {
|
||||||
let mut names = function::get_names(opts.show_hidden);
|
let mut names = function::get_names(opts.show_hidden, parser.vars());
|
||||||
names.sort();
|
names.sort();
|
||||||
if streams.out_is_terminal() {
|
if streams.out_is_terminal() {
|
||||||
let mut buff = WString::new();
|
let mut buff = WString::new();
|
||||||
|
|
|
@ -1086,7 +1086,7 @@ impl<'ctx> Completer<'ctx> {
|
||||||
if str_cmd.is_empty() || (!str_cmd.contains('/') && str_cmd.as_char_slice()[0] != '~') {
|
if str_cmd.is_empty() || (!str_cmd.contains('/') && str_cmd.as_char_slice()[0] != '~') {
|
||||||
let include_hidden = str_cmd.as_char_slice().first() == Some(&'_');
|
let include_hidden = str_cmd.as_char_slice().first() == Some(&'_');
|
||||||
// Append all known matching functions
|
// Append all known matching functions
|
||||||
let possible_comp: Vec<_> = function::get_names(include_hidden)
|
let possible_comp: Vec<_> = function::get_names(include_hidden, self.ctx.vars())
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(Completion::from_completion)
|
.map(Completion::from_completion)
|
||||||
.collect();
|
.collect();
|
||||||
|
|
|
@ -143,9 +143,7 @@ pub fn load(name: &wstr, parser: &Parser) -> bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Insert a list of all dynamically loaded functions into the specified list.
|
/// Insert a list of all dynamically loaded functions into the specified list.
|
||||||
fn autoload_names(names: &mut HashSet<WString>, get_hidden: bool) {
|
fn autoload_names(names: &mut HashSet<WString>, vars: &dyn Environment, get_hidden: bool) {
|
||||||
// TODO: justify this.
|
|
||||||
let vars = EnvStack::principal();
|
|
||||||
let Some(path_var) = vars.get_unless_empty(L!("fish_function_path")) else {
|
let Some(path_var) = vars.get_unless_empty(L!("fish_function_path")) else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
@ -319,10 +317,10 @@ pub fn copy(name: &wstr, new_name: WString, parser: &Parser) -> bool {
|
||||||
/// Returns all function names.
|
/// Returns all function names.
|
||||||
///
|
///
|
||||||
/// \param get_hidden whether to include hidden functions, i.e. ones starting with an underscore.
|
/// \param get_hidden whether to include hidden functions, i.e. ones starting with an underscore.
|
||||||
pub fn get_names(get_hidden: bool) -> Vec<WString> {
|
pub fn get_names(get_hidden: bool, vars: &dyn Environment) -> Vec<WString> {
|
||||||
let mut names = HashSet::<WString>::new();
|
let mut names = HashSet::<WString>::new();
|
||||||
let funcset = FUNCTION_SET.lock().unwrap();
|
let funcset = FUNCTION_SET.lock().unwrap();
|
||||||
autoload_names(&mut names, get_hidden);
|
autoload_names(&mut names, vars, get_hidden);
|
||||||
for name in funcset.funcs.keys() {
|
for name in funcset.funcs.keys() {
|
||||||
// Maybe skip hidden.
|
// Maybe skip hidden.
|
||||||
if !get_hidden && (name.is_empty() || name.char_at(0) == '_') {
|
if !get_hidden && (name.is_empty() || name.char_at(0) == '_') {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user