microsoft/typescript-styled-plugin

Send correct replacement range information (use OptionalReplacementSpan)

jasonwilliams opened this issue · 2 comments

Raised from: microsoft/vscode#134328
and: microsoft/vscode#134328 (comment)

It looks like this plugin doesn't send back the proper range information. meaning replacements and edits are a bit screwed up. OptionalReplacementSpan could help with this.

Looking at CompletionInfo theres a new property OptionalReplacementSpan I think maybe this needs adding. It could help with this issue

You can see we don't send it here:

function translateCompletionItemsToCompletionInfo(
typescript: typeof ts,
items: vscode.CompletionList
): ts.WithMetadata<ts.CompletionInfo> {
return {
metadata: {
isIncomplete: items.isIncomplete,
},
isGlobalCompletion: false,
isMemberCompletion: false,
isNewIdentifierLocation: false,
entries: items.items.map(x => translateCompetionEntry(typescript, x)),
};
}

Also, try setting the replacementSpan property for each CompletionEntry
https://github.com/microsoft/TypeScript/blob/main/lib/tsserverlibrary.d.ts#L6295

See microsoft/vscode#134328 (comment) for update. ReplacementSpan needs to be set inside of completionEntry