Civet icon indicating copy to clipboard operation
Civet copied to clipboard

vscode extension incorrectly autocomplete '@this.'

Open unlessgames opened this issue 1 year ago • 1 comments

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.

vsc_civet_this

unlessgames avatar Nov 30 '23 17:11 unlessgames

I spent some time looking at why this happens. I notice two things:

  1. connection.onCompletion gets called with the transpiled code with this 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:
  2. The source mapping places the cursor at the position between h and i in this.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.

edemaine avatar Dec 06 '23 15:12 edemaine