Skip to content

Commit 4ee4703

Browse files
authored
Merge pull request #5695 from benlangmuir/disable-typo-correct-index
2 parents 2ac37cb + c8f53ff commit 4ee4703

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

test/Sema/typo_correction.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// RUN: %target-parse-verify-swift
2+
// RUN: not %target-swift-frontend -parse -disable-typo-correction %s 2>&1 | %FileCheck %s -check-prefix=DISABLED
3+
// DISABLED-NOT: did you mean
24

35
// This is close enough to get typo-correction.
46
func test_short_and_close() {

tools/SourceKit/lib/SwiftLang/SwiftIndexing.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ void trace::initTraceFiles(trace::SwiftInvocation &SwiftArgs,
196196

197197
void SwiftLangSupport::indexSource(StringRef InputFile,
198198
IndexingConsumer &IdxConsumer,
199-
ArrayRef<const char *> Args,
199+
ArrayRef<const char *> OrigArgs,
200200
StringRef Hash) {
201201
std::string Error;
202202
auto InputBuf = ASTMgr->getMemoryBuffer(InputFile, Error);
@@ -214,6 +214,12 @@ void SwiftLangSupport::indexSource(StringRef InputFile,
214214
PrintingDiagnosticConsumer PrintDiags;
215215
CI.addDiagnosticConsumer(&PrintDiags);
216216

217+
// Add -disable-typo-correction, since the errors won't be captured in the
218+
// response, and it can be expensive to do typo-correction when there are many
219+
// errors, which is common in indexing.
220+
SmallVector<const char *, 16> Args(OrigArgs.begin(), OrigArgs.end());
221+
Args.push_back("-disable-typo-correction");
222+
217223
CompilerInvocation Invocation;
218224
bool Failed = getASTManager().initCompilerInvocation(Invocation, Args,
219225
CI.getDiags(),

0 commit comments

Comments
 (0)