Skip to content

Commit

Permalink
Prevent the same workspace from being lazily launched more than once (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
vinistock authored Oct 9, 2024
1 parent f21413e commit 2a36402
Showing 1 changed file with 7 additions and 1 deletion.
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

0 comments on commit 2a36402

Please sign in to comment.