Open spebl opened 1 month ago
@spebl can you summarize what work this issue is tracking? And whose team should be doing that work?
@bobbrow sorry for the delay, I wanted to take another look at this after my initial investigation to make sure I understand what is needed for C++ to support this feature request from vscode-copilot.
The request is to be able to provide IntelliSense for blocks of C++ code in the copilot chat window.
My understanding of the work required to support this is that our language services currently don't support code not backed by a file and in the "file uri" format. Along with this, it looks like IntelliSense server also relies on a file being present when setting up.
I was originally planning to do the work to support this, but it looks to be more involved than I originally anticipated.
At this point, I'm thinking we can treat this as a request from vscode-copilot and prioritize/triage it as seems appropriate. I'm happy to discuss what I've looked through so far and the ideas I had on how we can support this, as well as work on the implementation, but will defer to your team for prioritization.
Feature Request
VS Code recently enabled IntelliSense in copilot chat code blocks. Although this is mostly implemented in a language agnostic way, the C++ extension needs to make some changes to support this new format.
This is currently also being tracked for Python and Java (and built in by default for JS/TS): https://github.com/microsoft/pylance-release/issues/6008 https://github.com/redhat-developer/vscode-java/issues/3684
Initially looking into it, I see a few barriers to this working by default. -- we will usually bail out early if scheme is not "file" in some event handlers that we would want to support. -- we get most document/editor events for the code block, but it looks like we're not getting "didOpen" which we rely on to set up file context. -- document.uri.scheme === "vscode-chat-code-block" && document.languageId === "cpp"
Tips from vscode-copilot:
Areas to test The C++ extension should see TextDocuments for each chat code block
There will actually be two docs per code block, one with the scheme vscode-chat-code-block: and one with the scheme vscode-copilot-chat-code-block:. vscode-chat-code-block is the scheme used by VS Code core to provide basic intellisense (such as expand selection. vscode-copilot-chat-code-block is the scheme used by copilot to provide go to definition support. This is needed because copilot registers itself as the go to def provider for vscode-chat-code-block
Basic syntax language features — such bracket matching and Smart Selection — should always work
You should never see errors reported for code in chat code blocks
Try asking copilot to generate invalid code to confirm this
Test hovers and go to definition within a single code block
For example if you ask for binary search in c++, there should be a single code block that has these IntelliSense features
Make sure these features work for global symbols Also test IntelliSense for symbols defined within the block Check that any special c++ features in hovers (such as links) work as expected Make sure the code block IntelliSense observes any relevant workspace/project settings Test cross code block IntelliSense
Ask a questions such as binary search in c++ and follow up by asking write some tests for it. The second code block should use the binary search function defined in the first. Inside of the second code block you should be able to hover on it to see documentation and use go to definition on it
Test IntelliSense for workspace symbols
This feature is mostly handled by copilot but still worth testing. For it, as a @workspace question to find code in the workspace. For example, @workspace where's the code for binary search
Make sure can use hover, go to definition, go to implementation, and go to type definition for symbols that come from the workspace Make sure you can still use these features for globals and locals too Make sure that code in code blocks is never picked up as a reference
If a code block uses a global symbol for example, when you run find all references on that symbol in a normal workspace file, you should not see the use in the code block listed
Make sure symbols code blocks never shows up in workspace symbol search
Explore any c++ specific features/behavior of these IntelliSense features inside these chat code blocks
Think about if there's any additional IntelliSense features that would help users understand code inside of chat code blocks