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

Prevent the same workspace from being lazily launched more than once #2693

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion vscode/src/rubyLsp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export class RubyLsp {

// A URI => content map of virtual documents for delegate requests
private readonly virtualDocuments = new Map<string, string>();
private readonly workspacesBeingLaunched: Set<number> = new Set();

constructor(
context: vscode.ExtensionContext,
Expand Down Expand Up @@ -83,14 +84,18 @@ export class RubyLsp {
document.uri,
);

if (!workspaceFolder) {
if (
!workspaceFolder ||
this.workspacesBeingLaunched.has(workspaceFolder.index)
) {
return;
}

const workspace = this.getWorkspace(workspaceFolder.uri);

// If the workspace entry doesn't exist, then we haven't activated the workspace yet
if (!workspace) {
this.workspacesBeingLaunched.add(workspaceFolder.index);
await this.activateWorkspace(workspaceFolder, false);
}
}),
Expand Down Expand Up @@ -230,6 +235,7 @@ export class RubyLsp {
true,
);
await this.showFormatOnSaveModeWarning(workspace);
this.workspacesBeingLaunched.delete(workspaceFolder.index);
}

// Registers all extension commands. Commands can only be registered once, so this happens in the constructor. For
Expand Down
Loading