mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-22 13:18:59 +08:00
Correct highlighting of abbreviations
Abbreviation highlighting cannot use the snapshot environment because we do not know up-front which variables to capture. Will revisit this later.
This commit is contained in:
parent
82170b0862
commit
2d3e8ec0a9
|
@ -1207,6 +1207,12 @@ maybe_t<wcstring> expand_abbreviation(const wcstring &src, const environment_t &
|
|||
return none();
|
||||
}
|
||||
|
||||
maybe_t<wcstring> expand_abbreviation(const wcstring &src) {
|
||||
// FIXME: We use the principal environment stack because we don't know which variables need to
|
||||
// be captured in a snapshot.
|
||||
return expand_abbreviation(src, env_stack_t::principal());
|
||||
}
|
||||
|
||||
std::map<wcstring, wcstring> get_abbreviations() {
|
||||
// TODO: try to make this cheaper
|
||||
const auto &vars = env_stack_t::principal();
|
||||
|
|
|
@ -161,6 +161,7 @@ wcstring replace_home_directory_with_tilde(const wcstring &str, const environmen
|
|||
/// Abbreviation support. Expand src as an abbreviation, returning the expanded form if found,
|
||||
/// none() if not.
|
||||
maybe_t<wcstring> expand_abbreviation(const wcstring &src, const environment_t &vars);
|
||||
maybe_t<wcstring> expand_abbreviation(const wcstring &src);
|
||||
|
||||
/// \return a snapshot of all abbreviations as a map abbreviation->expansion.
|
||||
std::map<wcstring, wcstring> get_abbreviations();
|
||||
|
|
|
@ -1015,7 +1015,7 @@ static bool command_is_valid(const wcstring &cmd, enum parse_statement_decoratio
|
|||
if (!is_valid && function_ok) is_valid = function_exists_no_autoload(cmd, vars);
|
||||
|
||||
// Abbreviations
|
||||
if (!is_valid && abbreviation_ok) is_valid = expand_abbreviation(cmd, vars).has_value();
|
||||
if (!is_valid && abbreviation_ok) is_valid = expand_abbreviation(cmd).has_value();
|
||||
|
||||
// Regular commands
|
||||
if (!is_valid && command_ok) is_valid = path_get_path(cmd, NULL, vars);
|
||||
|
|
Loading…
Reference in New Issue
Block a user