mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-31 23:28:45 +00:00
Migrate the complete_custom transient command line pop to cleanup_t
This ensures that it gets cleaned up even if there is a mid-function return.
This commit is contained in:
parent
45b85d28bb
commit
5cadea0173
1 changed files with 3 additions and 3 deletions
|
@ -1336,10 +1336,13 @@ void completer_t::complete_custom(const wcstring &cmd, const wcstring &cmdline,
|
|||
// Perhaps set a transient commandline so that custom completions
|
||||
// buitin_commandline will refer to the wrapped command. But not if
|
||||
// we're doing autosuggestions.
|
||||
maybe_t<cleanup_t> remove_transient{};
|
||||
bool wants_transient = depth > 0 && !is_autosuggest;
|
||||
if (wants_transient) {
|
||||
ctx.parser->libdata().transient_commandlines.push_back(cmdline);
|
||||
remove_transient.emplace([&] { ctx.parser->libdata().transient_commandlines.pop_back(); });
|
||||
}
|
||||
|
||||
maybe_t<size_t> equals_pos = variable_assignment_equals_pos(cmd);
|
||||
bool is_variable_assignment = bool(equals_pos);
|
||||
if (is_variable_assignment && !is_autosuggest) {
|
||||
|
@ -1385,9 +1388,6 @@ void completer_t::complete_custom(const wcstring &cmd, const wcstring &cmdline,
|
|||
!had_ddash)) { // Invoke any custom completions for this command.
|
||||
*do_file = false;
|
||||
}
|
||||
if (wants_transient) {
|
||||
ctx.parser->libdata().transient_commandlines.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
// Given a command line \p command_line and the range of the command itself within the
|
||||
|
|
Loading…
Reference in a new issue