Civet
Civet copied to clipboard
vscode extension incorrectly autocomplete '@this.'
When writing for a class in vscode using @
, and accepting an autocomplete suggestion regarding class members vscode adds the redundant this.
making the expression into an error.
I spent some time looking at why this happens. I notice two things:
-
connection.onCompletion
gets called with the transpiled code withthis
in it, but no characters after (no.so
). I believe there are a couple of reasons:- Our delayed scheduling of transpilation updates. Adding
await executeQueue()
seems to fix this. - The LSP model encourages clients to filter the original completion list instead of recomputing. I think this is only an issue when adding
@
as a trigger key, which I was also testing. This can be fixed by returning{ items: convertCompletions(completions), isIncomplete: true }
. - So I think I can fix this issue, except:
- Our delayed scheduling of transpilation updates. Adding
- The source mapping places the cursor at the position between
h
andi
inthis.s
, so TS gives the wrong completion.
So ultimately this seems to be a source mapping issue. I'm not quite sure how to debug this part.