mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 05:28:49 +00:00
When autoloading a completion, also autoload the function
Fixes a case where a --wraps declaration would be missed because the function would not be loaded. Fixes #2466.
This commit is contained in:
parent
434eabb787
commit
d9d2f61ba6
4 changed files with 20 additions and 14 deletions
|
@ -75,6 +75,8 @@ static const wcstring &C_(const wcstring &s)
|
|||
}
|
||||
#endif
|
||||
|
||||
static void complete_load(const wcstring &name, bool reload);
|
||||
|
||||
/* Testing apparatus */
|
||||
const wcstring_list_t *s_override_variable_names = NULL;
|
||||
|
||||
|
@ -1316,8 +1318,13 @@ static int short_ok(const wcstring &arg_str, wchar_t nextopt, const wcstring &al
|
|||
return 1;
|
||||
}
|
||||
|
||||
void complete_load(const wcstring &name, bool reload)
|
||||
|
||||
/* Load command-specific completions for the specified command. */
|
||||
static void complete_load(const wcstring &name, bool reload)
|
||||
{
|
||||
// we have to load this as a function, since it may define a --wraps or signature
|
||||
// see #2466
|
||||
function_load(name);
|
||||
completion_autoloader.load(name, reload);
|
||||
}
|
||||
|
||||
|
|
|
@ -234,19 +234,6 @@ bool complete_is_valid_argument(const wcstring &str,
|
|||
const wcstring &arg);
|
||||
|
||||
|
||||
/**
|
||||
Load command-specific completions for the specified command. This
|
||||
is done automatically whenever completing any given command, so
|
||||
there is no need to call this except in the case of completions
|
||||
with internal dependencies.
|
||||
|
||||
\param cmd the command for which to load command-specific completions
|
||||
\param reload should the commands completions be reloaded, even if they where
|
||||
previously loaded. (This is set to true on actual completions, so that
|
||||
changed completion are updated in running shells)
|
||||
*/
|
||||
void complete_load(const wcstring &cmd, bool reload);
|
||||
|
||||
/**
|
||||
Create a new completion entry
|
||||
|
||||
|
|
|
@ -222,6 +222,15 @@ int function_exists(const wcstring &cmd)
|
|||
return loaded_functions.find(cmd) != loaded_functions.end();
|
||||
}
|
||||
|
||||
void function_load(const wcstring &cmd)
|
||||
{
|
||||
if (! parser_keywords_is_reserved(cmd))
|
||||
{
|
||||
scoped_lock lock(functions_lock);
|
||||
load(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
int function_exists_no_autoload(const wcstring &cmd, const env_vars_snapshot_t &vars)
|
||||
{
|
||||
if (parser_keywords_is_reserved(cmd))
|
||||
|
|
|
@ -130,6 +130,9 @@ void function_set_desc(const wcstring &name, const wcstring &desc);
|
|||
*/
|
||||
int function_exists(const wcstring &name);
|
||||
|
||||
/** Attempts to load a function if not yet loaded. This is used by the completion machinery. */
|
||||
void function_load(const wcstring &name);
|
||||
|
||||
/**
|
||||
Returns true if the function with the name name exists, without triggering autoload.
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue