Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/services/completions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ export function getCompletionsAtPosition(
const compilerOptions = program.getCompilerOptions();
const incompleteCompletionsCache = preferences.allowIncompleteCompletions ? host.getIncompleteCompletionsCache?.() : undefined;
if (incompleteCompletionsCache && completionKind === CompletionTriggerKind.TriggerForIncompleteCompletions && previousToken && isIdentifier(previousToken)) {
const incompleteContinuation = continuePreviousIncompleteResponse(incompleteCompletionsCache, sourceFile, previousToken, program, host, preferences, cancellationToken);
const incompleteContinuation = continuePreviousIncompleteResponse(incompleteCompletionsCache, sourceFile, previousToken, program, host, preferences, cancellationToken, position);
if (incompleteContinuation) {
return incompleteContinuation;
}
Expand Down Expand Up @@ -750,10 +750,12 @@ function continuePreviousIncompleteResponse(
host: LanguageServiceHost,
preferences: UserPreferences,
cancellationToken: CancellationToken,
position: number,
): CompletionInfo | undefined {
const previousResponse = cache.get();
if (!previousResponse) return undefined;

const touchNode = getTouchingPropertyName(file, position);
const lowerCaseTokenText = location.text.toLowerCase();
const exportMap = getExportInfoMap(file, host, program, preferences, cancellationToken);
const newEntries = resolvingModuleSpecifiers(
Expand Down Expand Up @@ -809,6 +811,7 @@ function continuePreviousIncompleteResponse(

previousResponse.entries = newEntries;
previousResponse.flags = (previousResponse.flags || 0) | CompletionInfoFlags.IsContinuation;
previousResponse.optionalReplacementSpan = getOptionalReplacementSpan(touchNode);
return previousResponse;
}

Expand Down
2 changes: 2 additions & 0 deletions src/testRunner/unittests/tsserver/completionsIncomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,12 @@ describe("unittests:: tsserver:: completionsIncomplete", () => {
assert(completions.isIncomplete);
assert.lengthOf(completions.entries.filter(entry => (entry.data as any)?.moduleSpecifier), ts.Completions.moduleSpecifierResolutionLimit);
assert.lengthOf(completions.entries.filter(entry => entry.source && !(entry.data as any)?.moduleSpecifier), excessFileCount);
assert.deepEqual(completions.optionalReplacementSpan, { start: { line: 1, offset: 1 }, end: { line: 1, offset: 2 } });
})
.continueTyping("a", completions => {
assert(completions.isIncomplete);
assert.lengthOf(completions.entries.filter(entry => (entry.data as any)?.moduleSpecifier), ts.Completions.moduleSpecifierResolutionLimit * 2);
assert.deepEqual(completions.optionalReplacementSpan, { start: { line: 1, offset: 1 }, end: { line: 1, offset: 3 } });
})
.continueTyping("_", completions => {
assert(!completions.isIncomplete);
Expand Down