Skip to content

Commit edbee9e

Browse files
authored
Merge pull request swiftlang#63126 from poya/bug/62802
[IDE] Fix crash in common root search in REPL code completion
2 parents 721e3e9 + fd5c56e commit edbee9e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/IDE/REPLCodeCompletion.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,12 +315,17 @@ StringRef REPLCompletions::getRoot() const {
315315

316316
std::string RootStr = CookedResults[0].InsertableString.str();
317317
for (auto R : CookedResults) {
318+
if (RootStr.empty())
319+
break;
320+
318321
if (R.NumBytesToErase != 0) {
319322
RootStr.resize(0);
320323
break;
321324
}
322-
auto MismatchPlace = std::mismatch(RootStr.begin(), RootStr.end(),
323-
R.InsertableString.begin());
325+
326+
auto MismatchPlace =
327+
std::mismatch(RootStr.begin(), RootStr.end(),
328+
R.InsertableString.begin(), R.InsertableString.end());
324329
RootStr.resize(MismatchPlace.first - RootStr.begin());
325330
}
326331
Root = RootStr;

0 commit comments

Comments
 (0)