From 2da0f54c7503a5faaf4d770e58eb97eb7b6dde64 Mon Sep 17 00:00:00 2001 From: Vinicius Stock Date: Tue, 8 Oct 2024 17:07:26 -0400 Subject: [PATCH] Prevent the same workspace from being lazily launched more than once --- vscode/src/rubyLsp.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/vscode/src/rubyLsp.ts b/vscode/src/rubyLsp.ts index 3c2c2ee6f..2f28b6a81 100644 --- a/vscode/src/rubyLsp.ts +++ b/vscode/src/rubyLsp.ts @@ -33,6 +33,7 @@ export class RubyLsp { // A URI => content map of virtual documents for delegate requests private readonly virtualDocuments = new Map(); + private readonly workspacesBeingLaunched: Set = new Set(); constructor( context: vscode.ExtensionContext, @@ -83,7 +84,10 @@ export class RubyLsp { document.uri, ); - if (!workspaceFolder) { + if ( + !workspaceFolder || + this.workspacesBeingLaunched.has(workspaceFolder.index) + ) { return; } @@ -91,6 +95,7 @@ export class RubyLsp { // 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); } }), @@ -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