Allow cancellation out of expanding a runaway wrap chain

This makes it easier to control-C out of a completion.
This commit is contained in:
ridiculousfish
2019-09-21 13:11:45 -07:00
parent 3f2f44ce73
commit 77dbe109e0

View File

@@ -1083,6 +1083,7 @@ bool completer_t::complete_param(const wcstring &cmd_orig, const wcstring &popt,
/// Perform generic (not command-specific) expansions on the specified string.
void completer_t::complete_param_expand(const wcstring &str, bool do_file,
bool handle_as_special_cd) {
if (reader_test_should_cancel()) return;
expand_flags_t flags =
this->expand_flags() | expand_flag::skip_cmdsubst | expand_flag::for_completions;
@@ -1318,6 +1319,7 @@ static void walk_wrap_chain(const wcstring &command_line, source_range_t command
const wrap_chain_visitor_t &visitor, size_t depth = 0) {
// Limit our recursion depth. This prevents cycles in the wrap chain graph from overflowing.
if (depth > 24) return;
if (reader_test_should_cancel()) return;
// Extract command from the command line and invoke the receiver with it.
wcstring command(command_line, command_range.start, command_range.length);