From 7bdc712615f46d4fdbb0b2f1952407c21968241a Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sat, 16 Jul 2022 16:34:44 +0200 Subject: [PATCH] Clean up weird edge-case for escaping unescaped brackets As explained by the comment, this was dead code. If it were ever executed, it would cause very weird behavior because it would make some completions randomly affect others. Let's just print a warning (maybe this is better than crashing?). --- src/complete.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/complete.cpp b/src/complete.cpp index 838e72a1a..fcbfb9e89 100644 --- a/src/complete.cpp +++ b/src/complete.cpp @@ -1436,11 +1436,12 @@ void completer_t::escape_opening_brackets(const wcstring &argument) { if (comp.flags & COMPLETE_REPLACES_TOKEN) continue; comp.flags |= COMPLETE_REPLACES_TOKEN; comp.flags |= COMPLETE_DONT_ESCAPE_TILDES; // See #9073. + // We are grafting a completion that is expected to be escaped later. This will break + // if the original completion doesn't want escaping. Happily, this is only the case + // for username completion and variable name completion. They shouldn't end up here + // anyway because they won't contain '['. if (comp.flags & COMPLETE_DONT_ESCAPE) { - // If the completion won't be escaped, we need to do it here. - // Currently, this will probably never happen since COMPLETE_DONT_ESCAPE - // is only set for user or variable names which cannot contain '['. - unescaped_argument = escape_string(unescaped_argument, ESCAPE_ALL); + FLOG(warning, L"unexpected completion flag"); } comp.completion = unescaped_argument + comp.completion; }