Skip to content

optionalReplacementSpan not update when hit a incompleteCompletionsCache? #52270

@jadestrong

Description

@jadestrong

if (incompleteCompletionsCache && completionKind === CompletionTriggerKind.TriggerForIncompleteCompletions && previousToken && isIdentifier(previousToken)) {
const incompleteContinuation = continuePreviousIncompleteResponse(incompleteCompletionsCache, sourceFile, previousToken, program, host, preferences, cancellationToken);
if (incompleteContinuation) {
return incompleteContinuation;
}

Here when hit a cache, will directly return the cached one, but in the continuePreviousIncompleteResponse function, not sync the optionalReplacementSpan' value, so there will always return the cached optionalReplacementSpan value.
optionalReplacementSpan: getOptionalReplacementSpan(location),

But typescript-language-server and volar all use this field to calculate CompletionItem's textEdit (InsertReplaceEdit) field.
https://github.com/typescript-language-server/typescript-language-server/blob/d8b4cb698b6b74f12edb0a19e6c28b391cc0e985/src/completion.ts#L104

https://github.com/volarjs/plugins/blob/3c62a892e334806d2b76cd66d9c4670179d21398/packages/typescript/src/services/completions/basic.ts#L51-L54

So, should this field also be updated here? or is typescript-language-server need calculated in other ways?

Here is the first time hit a isInComplete, the optionalReplacementSpan' end is {line: 100, offset: 18}

image

Then the following inputs hit the cache, trigger position is changed, but optionalReplacementSpan are not updated
image

image

Metadata

Metadata

Assignees

Labels

APIRelates to the public API for TypeScriptDomain: Auto-importDomain: Completion ListsThe issue relates to showing completion lists in an editorDomain: TSServerIssues related to the TSServer

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions