diff --git a/complete.cpp b/complete.cpp index 57720e6d0..06da23d8a 100644 --- a/complete.cpp +++ b/complete.cpp @@ -1159,18 +1159,19 @@ void completer_t::complete_from_args( const wcstring &str, const wcstring &desc, complete_flags_t flags ) { - /* If type is COMPLETE_AUTOSUGGEST, it means we're on a background thread, so don't call proc_push_interactive */ std::vector possible_comp; - parser_t parser(PARSER_TYPE_COMPLETIONS_ONLY); - - if (this->type != COMPLETE_AUTOSUGGEST) + bool is_autosuggest = (this->type == COMPLETE_AUTOSUGGEST); + parser_t parser(is_autosuggest ? PARSER_TYPE_COMPLETIONS_ONLY : PARSER_TYPE_GENERAL); + + /* If type is COMPLETE_AUTOSUGGEST, it means we're on a background thread, so don't call proc_push_interactive */ + if (is_autosuggest) proc_push_interactive(0); parser.eval_args( args.c_str(), possible_comp ); - if (this->type != COMPLETE_AUTOSUGGEST) + if (is_autosuggest) proc_pop_interactive(); complete_strings( this->completions, str.c_str(), desc.c_str(), 0, possible_comp, flags ); diff --git a/parser.cpp b/parser.cpp index 33f510285..513bf316c 100644 --- a/parser.cpp +++ b/parser.cpp @@ -767,7 +767,7 @@ int parser_t::eval_args( const wchar_t *line, std::vector &args ) expand_flags_t eflags = 0; if (! show_errors) eflags |= EXPAND_NO_DESCRIPTIONS; - if (this->parser_type != PARSER_TYPE_GENERAL && this->parser_type != PARSER_TYPE_COMPLETIONS_ONLY) + if (this->parser_type != PARSER_TYPE_GENERAL) eflags |= EXPAND_SKIP_CMDSUBST; /*