mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 05:13:10 +00:00
Merge branch 'master' into pager
This commit is contained in:
commit
9f3a16a4ae
3 changed files with 24 additions and 17 deletions
31
complete.cpp
31
complete.cpp
|
@ -281,21 +281,26 @@ completion_t::~completion_t()
|
|||
{
|
||||
}
|
||||
|
||||
/* completion_t functions */
|
||||
completion_t::completion_t(const wcstring &comp, const wcstring &desc, string_fuzzy_match_t mat, int flags_val) :
|
||||
completion(comp),
|
||||
description(desc),
|
||||
match(mat),
|
||||
flags(flags_val)
|
||||
/* Clear the COMPLETE_AUTO_SPACE flag, and set COMPLETE_NO_SPACE appropriately depending on the suffix of the string */
|
||||
static complete_flags_t resolve_auto_space(const wcstring &comp, complete_flags_t flags)
|
||||
{
|
||||
if (flags & COMPLETE_AUTO_SPACE)
|
||||
{
|
||||
flags = flags & ~COMPLETE_AUTO_SPACE;
|
||||
size_t len = completion.size();
|
||||
size_t len = comp.size();
|
||||
if (len > 0 && (wcschr(L"/=@:", comp.at(len-1)) != 0))
|
||||
flags |= COMPLETE_NO_SPACE;
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
/* completion_t functions. Note that the constructor resolves flags! */
|
||||
completion_t::completion_t(const wcstring &comp, const wcstring &desc, string_fuzzy_match_t mat, complete_flags_t flags_val) :
|
||||
completion(comp),
|
||||
description(desc),
|
||||
match(mat),
|
||||
flags(resolve_auto_space(comp, flags_val))
|
||||
{
|
||||
}
|
||||
|
||||
completion_t::completion_t(const completion_t &him) : completion(him.completion), description(him.description), match(him.match), flags(him.flags)
|
||||
|
@ -463,16 +468,18 @@ void completion_autoload_t::command_removed(const wcstring &cmd)
|
|||
}
|
||||
|
||||
|
||||
/** Create a new completion entry */
|
||||
/** Create a new completion entry. */
|
||||
void append_completion(std::vector<completion_t> &completions, const wcstring &comp, const wcstring &desc, complete_flags_t flags, string_fuzzy_match_t match)
|
||||
{
|
||||
/* If we just constructed the completion and used push_back, we would get two string copies. Try to avoid that by making a stubby completion in the vector first, and then copying our string in. */
|
||||
completions.push_back(completion_t(wcstring()));
|
||||
/* If we just constructed the completion and used push_back, we would get two string copies. Try to avoid that by making a stubby completion in the vector first, and then copying our string in. Note that completion_t's constructor will munge 'flags' so it's important that we pass those to the constructor.
|
||||
|
||||
Nasty hack for #1241 - since the constructor needs the completion string to resolve AUTO_SPACE, and we aren't providing it with the completion, we have to do the resolution ourselves. We should get this resolving out of the constructor.
|
||||
*/
|
||||
const wcstring empty;
|
||||
completions.push_back(completion_t(empty, empty, match, resolve_auto_space(comp, flags)));
|
||||
completion_t *last = &completions.back();
|
||||
last->completion = comp;
|
||||
last->description = desc;
|
||||
last->match = match;
|
||||
last->flags = flags;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -121,10 +121,10 @@ public:
|
|||
The COMPLETE_NO_CASE can be used to signal that this completion
|
||||
is case insensitive.
|
||||
*/
|
||||
int flags;
|
||||
complete_flags_t flags;
|
||||
|
||||
/* Construction. Note: defining these so that they are not inlined reduces the executable size. */
|
||||
completion_t(const wcstring &comp, const wcstring &desc = wcstring(), string_fuzzy_match_t match = string_fuzzy_match_t(fuzzy_match_exact), int flags_val = 0);
|
||||
completion_t(const wcstring &comp, const wcstring &desc = wcstring(), string_fuzzy_match_t match = string_fuzzy_match_t(fuzzy_match_exact), complete_flags_t flags_val = 0);
|
||||
completion_t(const completion_t &);
|
||||
completion_t &operator=(const completion_t &);
|
||||
|
||||
|
|
|
@ -1065,10 +1065,10 @@ static parse_keyword_t keyword_for_token(token_type tok, const wchar_t *tok_txt)
|
|||
}
|
||||
|
||||
/* Placeholder invalid token */
|
||||
static const parse_token_t kInvalidToken = {token_type_invalid, parse_keyword_none, false, -1, -1};
|
||||
static const parse_token_t kInvalidToken = {token_type_invalid, parse_keyword_none, false, false, -1, -1};
|
||||
|
||||
/* Terminal token */
|
||||
static const parse_token_t kTerminalToken = {parse_token_type_terminate, parse_keyword_none, false, -1, -1};
|
||||
static const parse_token_t kTerminalToken = {parse_token_type_terminate, parse_keyword_none, false, false, -1, -1};
|
||||
|
||||
static inline bool is_help_argument(const wchar_t *txt)
|
||||
{
|
||||
|
@ -1158,7 +1158,7 @@ bool parse_tree_from_string(const wcstring &str, parse_tree_flags_t parse_flags,
|
|||
size_t error_token_idx = (queue[1].type == parse_special_type_tokenizer_error ? 1 : 0);
|
||||
|
||||
/* Mark a special error token, and then keep going */
|
||||
const parse_token_t token = {parse_special_type_parse_error, parse_keyword_none, false, queue[error_token_idx].source_start, queue[error_token_idx].source_length};
|
||||
const parse_token_t token = {parse_special_type_parse_error, parse_keyword_none, false, false, queue[error_token_idx].source_start, queue[error_token_idx].source_length};
|
||||
parser.accept_tokens(token, kInvalidToken);
|
||||
parser.reset_symbols();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue