microsoft / pylance-release

Documentation and issues for Pylance
Creative Commons Attribution 4.0 International
1.67k stars 770 forks source link

Explore Python IntelliSense in Copilot chat code blocks #6008

Open mjbvz opened 2 weeks ago

mjbvz commented 2 weeks ago

This is an open ended, exploratory item

VS Code recently enabled intellisense in copilot chat code blocks. Although this is mostly implemented in a language agnostic way, language extensions may need to make some changes to get the best support

For this exploration, I'd like the python team's help testing out IntelliSense in copilot chat code blocks. I've provided a list of ideas on what to test below, however feel free to build on it. I've gone through them for JS/TS and found them to be a good starting point. You can also file feature request against VS Code for new feature ideas

Areas to test

rchiodo commented 2 weeks ago

I'm wondering if our import resolution is going to work. The schema will make us think the file is not on the local file system, so we won't search the workspace. We might have to special case the schema here.

heejaechang commented 2 weeks ago

default workspace might work with stdlib with any random url in async server. but that said, feels like it might be better to just create new workspace that deals with copilot specifically? like copilotWorkspace ? and we enable or disable certain features there?

luabud commented 2 weeks ago

next week I'll try to look more deeply into this, since right now we only support vscode-chat-code-block and I was struggling to get a Pylance build with vscode-copilot-chat-code-block and I'm not sure why.

But so far I noticed that when Copilot uses one of the workspace files as reference, go to def and hover works as expected. With reference:

Image

No reference (nothing shows when hovering models)

Image

Also noticed that go to definition on .models takes to the Django built-in models module, not my models.py file. But the classes go to the models.py as expected:

Image

Image

Errors are not being displayed indeed, although a few diagnostics such as unaccessed symbol or unreachable code are displayed (note that the "experimental pylance" string is a known bug that has just recently been fixed):

Image

Image

Apart from that, everything else worked well: bracket matching, smart selection, go to def on global variables, response results not showing on symbol search