complete: use remove_if+erase instead of raw loop to remove leading decorators

In theory this does less work so we should generally use this style.
In practice it looks uglier so I'm not sure. Maybe wait for stdlib ranges...

No functional change.
This commit is contained in:
Johannes Altmanninger 2022-09-15 04:07:25 +02:00
parent 613ecfc7e4
commit b3a8e85b0f

View file

@ -1511,8 +1511,12 @@ void completer_t::perform_for_commandline(wcstring cmdline) {
// Hack: fix autosuggestion by removing prefixing "and"s #6249.
if (is_autosuggest) {
while (!tokens.empty() && parser_keywords_is_subcommand(tokens.front().get_source(cmdline)))
tokens.erase(tokens.begin());
tokens.erase(
std::remove_if(tokens.begin(), tokens.end(),
[&cmdline](const tok_t &token) {
return parser_keywords_is_subcommand(token.get_source(cmdline));
}),
tokens.end());
}
// Consume variable assignments in tokens strictly before the cursor.