mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-01 04:41:14 -03:00
Restore $status after expanding completions
When a completion's "--arguments" script ran, it would clobber $status with its value, so when you repainted your prompt, it would now show the completion script's status rather than the status of what you last ran. Solve this by just storing the status and restoring it - other places do this by calling exec_subshell with apply_exit_status set to false, which does basically the same thing. We can't use it here because we don't want to run a "full" script, we only want the arguments to be expanded, without a "real" command. No, I have no idea how to test this automatically. Fixes #7555.
This commit is contained in:
@@ -808,9 +808,11 @@ void completer_t::complete_from_args(const wcstring &str, const wcstring &args,
|
||||
bool is_autosuggest = (this->type() == COMPLETE_AUTOSUGGEST);
|
||||
|
||||
bool saved_interactive = false;
|
||||
statuses_t status;
|
||||
if (ctx.parser) {
|
||||
saved_interactive = ctx.parser->libdata().is_interactive;
|
||||
ctx.parser->libdata().is_interactive = false;
|
||||
status = ctx.parser->get_last_statuses();
|
||||
}
|
||||
|
||||
expand_flags_t eflags{};
|
||||
@@ -822,6 +824,7 @@ void completer_t::complete_from_args(const wcstring &str, const wcstring &args,
|
||||
|
||||
if (ctx.parser) {
|
||||
ctx.parser->libdata().is_interactive = saved_interactive;
|
||||
ctx.parser->set_last_statuses(status);
|
||||
}
|
||||
|
||||
this->complete_strings(escape_string(str, ESCAPE_ALL), const_desc(desc), possible_comp, flags);
|
||||
|
||||
Reference in New Issue
Block a user