mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-28 05:43:11 +00:00
Fix traversal order of tokens in history completion
Fixes an issue introduced by e51e854
. Closes #5150.
This commit is contained in:
parent
e8a35bfaa8
commit
1c59a3f1a8
1 changed files with 8 additions and 1 deletions
|
@ -187,13 +187,20 @@ class reader_history_search_t {
|
|||
const wcstring &needle = search_string();
|
||||
tokenizer_t tok(text.c_str(), TOK_ACCEPT_UNFINISHED);
|
||||
tok_t token;
|
||||
|
||||
std::vector<wcstring> local_tokens;
|
||||
while (tok.next(&token)) {
|
||||
if (token.type != TOK_STRING) continue;
|
||||
wcstring text = tok.text_of(token);
|
||||
if (text.find(needle) != wcstring::npos) {
|
||||
add_if_new(std::move(text));
|
||||
local_tokens.emplace_back(std::move(text));
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure tokens are added in reverse order. See #5150
|
||||
for (auto i = local_tokens.rbegin(); i != local_tokens.rend(); ++i) {
|
||||
add_if_new(std::move(*i));
|
||||
}
|
||||
}
|
||||
return matches_.size() > before;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue