Inconsistent replacement span inclusion between member completion types #57601
Labels
Bug
A bug in TypeScript
Domain: Completion Lists
The issue relates to showing completion lists in an editor
Help Wanted
You can do this
Milestone
π Search Terms
replacement span member completion optional insert mode replace suggest
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play?ts=5.5.0-dev.20240301#code/C4TwDgpgBAysCGxoF4oG8BQUoQCYHMIAlCAMwGcAuKc4AJwEsA7fAbQF0BuLKJge1zEyVGvWZsuGAL7cMAYz5NaoxBGpxVUVJmz9BJCtQ4AaHkMNQT02QqXAVSAEzqESLeh57zIq9gBE3n5G7KYyGEA
π» Code
π Actual behavior
Completion at 1 comes with an optional replacement range but no entry-level replacement range. Completion at 2 comes with both
π Expected behavior
I see both of those to be the same type of completions - they both are meant to suggest members. For that reason, I'd expect both of those to have very similar payload
Additional information about the issue
I proposed to use
optionalReplacementRange
in absence ofreplacementRange
here: microsoft/monaco-editor#4406Currently, VS Code Insiders (ee69e2887fbe532588f74ae86560e7fdc1e59550) behaves the same way as TS playground with
editor.suggest.insertMode: 'insert'
. However, the same change (as the one that I proposed for Monaco) can't be introduced in VS Code. In fact, it briefly got introduced recently there in microsoft/vscode#200945 but later the behavior got changed/tweaked after bug reports came in. You can see the recent history of the changes hereI studied that recent history a little bit and it seems that
replacementSpan
andoptionalReplacementSpan
do not represent the same thing so such reuse is not always safe. I didn't have time to study in depth when they are different and why (beyond noticing - based on one of the reported issues - that some completions for imports have them different).I believe that the current behavior in VS Code at the marker 2 is incorrect with
editor.suggest.insertMode: 'insert'
. I've struggled with where I should report this but I concluded that in great part the reason why this behaves differently on VS Code side of things is that TS includes thisreplacementSpan
inconsistently at those 2 markers so I chose to report this here first.cc @andrewbranch @mjbvz (you both were involved in the recent changes around this in VS Code repo)
The text was updated successfully, but these errors were encountered: