From 3b6770d48d3fd636de9f27295c23ce9946a65214 Mon Sep 17 00:00:00 2001 From: Vinicius Stock Date: Tue, 9 Jul 2024 16:50:37 -0400 Subject: [PATCH] Return early when fetching dependencies if client is not running (#2276) --- vscode/src/dependenciesTree.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/vscode/src/dependenciesTree.ts b/vscode/src/dependenciesTree.ts index c162edd1f..dfc88552d 100644 --- a/vscode/src/dependenciesTree.ts +++ b/vscode/src/dependenciesTree.ts @@ -1,6 +1,7 @@ import path from "path"; import * as vscode from "vscode"; +import { State } from "vscode-languageclient"; import { STATUS_EMITTER, WorkspaceInterface } from "./common"; @@ -148,11 +149,17 @@ export class DependenciesTree private async fetchDependencies(): Promise { this.gemRootFolders = {}; - if (!this.currentWorkspace || !this.currentWorkspace.lspClient) { + if (!this.currentWorkspace) { return []; } - const resp = (await this.currentWorkspace.lspClient.sendRequest( + const client = this.currentWorkspace.lspClient; + + if (!client || client.state !== State.Running) { + return []; + } + + const resp = (await client.sendRequest( "rubyLsp/workspace/dependencies", {}, )) as [