Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove extra didOpen message sent from our end #7173

Merged
merged 1 commit into from
Sep 27, 2022
Merged

Remove extra didOpen message sent from our end #7173

merged 1 commit into from
Sep 27, 2022

Conversation

StellaHuang95
Copy link
Contributor

fixes #7115

Pylance used to require a new open notification after a workspace folder change (not sure if it still requires now). The code in PythonLanguageClient.cs was a requirement of pylance to force a reopen on all documents whenever the current workspace folder changed (opening a solution would provide the base folder for the workspace).

This makes sense in VSCode, because VS Code allows you to open multiple folders at a time. So adding or removing WorkspaceFolders makes sense there. But in VS, it does not support opening multiple workspace folders at the same time. When you close the current workspace (i.e. close all open folders) and open a new one in VS, we just start a new instance of Pylance.

The LSP spec says that the workspace/didChangeWorkspaceFolders should be sent for "workspace folder configuration changes" which is not very specific. But the didChangeWorkspaceFolder message only contains added/removed arrays of WorkspaceFolder objects, and those objects just contain the folder uri and folder name (to show in UI), so I can't think of another scenario where the message would need to be sent other than opening/closing a solution/workspace.

LSP Client already sends at least one didOpen anytime documents are opened, so it should be ok to remove the extra didOpen from PTVS. It can be sent in whichever of these two places is hit first:

Also tested the change in both open folder and project view scenarios, pylance still works well after the change.

@StellaHuang95 StellaHuang95 requested a review from a team as a code owner September 26, 2022 21:46
@sonarcloud
Copy link

sonarcloud bot commented Sep 26, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@StellaHuang95 StellaHuang95 merged commit 99d4d6e into main Sep 27, 2022
@StellaHuang95 StellaHuang95 deleted the didOpen branch September 27, 2022 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ILanguageClient implementation can cause race condition by sending extra didOpen notification
2 participants