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

Fix missing imports due to pylance thinking open documents are under default workspace #8033

Merged
merged 6 commits into from
Oct 21, 2024

Conversation

bschnurr
Copy link
Member

  • inject workspace definitions into the "initialize" call to pylance so that there is no chance of a textdocument/didopen call triggering the creation of a dfeault workspace before getfolders is called to setup the workspace.

… we wont be creating a default workspace if textdocument/didopen is sent before workspacefolders are updated
@bschnurr bschnurr requested a review from a team as a code owner October 21, 2024 17:20
@@ -593,24 +590,35 @@ private Tuple<StreamData, bool> OnSendToServer(StreamData data) {
return Tuple.Create(data, true);
}

private async Task OnWorkspaceOpening(object sende, EventArgs e) {
private IEnumerable<WorkspaceFolder> GetFolders() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you have this always return a list? Every place you call it you're turning it into a list.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true. such a small list. no reason to make it enumerable

@@ -138,7 +135,7 @@ public async Task<Connection> ActivateAsync(CancellationToken token) {
await JoinableTaskContext.Factory.SwitchToMainThreadAsync();
CreateClientContexts();

_deferredSettingsChangedTimer = new Timer(OnDeferredSettingsChanged, state: null, Timeout.Infinite, Timeout.Infinite);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just replacing this function with a lamda to cut down on fuctions

return InvokeDidChangeConfigurationAsync(new LSP.DidChangeConfigurationParams() {
// Pylance will ask us for per workspace configuration settings. We can send
// default workspace settings here.
Settings = GetSettings()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now include actual settings which get applied to any default workspace

Copy link

sonarcloud bot commented Oct 21, 2024

@bschnurr bschnurr merged commit 970eec2 into microsoft:main Oct 21, 2024
6 checks passed
@bschnurr bschnurr deleted the fix-pylance-workspace branch October 21, 2024 21:38
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.

2 participants