mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-07 18:21:16 -03:00
Fix completion for builtins (with subcommands)
Presently the completion engine ignores builtins that are part of the fish syntax. This can be a problem when completing a string that was based on the output of `commandline -p`. This changes completions to treat these builtins like any other command. This also disables generic (filename) completion inside comments and after strings that do not tokenize. Additionally, comments are stripped off the output of `commandline -p`. Fixes #5415 Fixes #2705
This commit is contained in:
@@ -87,6 +87,13 @@ struct tok_t {
|
||||
|
||||
// Construct from a token type.
|
||||
explicit tok_t(token_type_t type);
|
||||
|
||||
/// Returns whether the given location is within the source range or at its end.
|
||||
bool location_in_or_at_end_of_source_range(size_t loc) const {
|
||||
return offset <= loc && loc - offset <= length;
|
||||
}
|
||||
/// Gets source for the token, or the empty string if it has no source.
|
||||
wcstring get_source(const wcstring &str) const { return {str, offset, length}; }
|
||||
};
|
||||
|
||||
/// The tokenizer struct.
|
||||
|
||||
Reference in New Issue
Block a user