diff --git a/client/src/commands.ts b/client/src/commands.ts index 3bf05fde..08bca116 100644 --- a/client/src/commands.ts +++ b/client/src/commands.ts @@ -93,6 +93,10 @@ export function startLanguageServer( } extensionContext.clientSubscriptions = []; + if (isDenoDisabledCompletely()) { + return; + } + // Start a new language server const command = await getDenoCommandPath(); if (command == null) { @@ -438,3 +442,21 @@ export function disable( await config.update("enable", false); }; } + +function isDenoDisabledCompletely(): boolean { + function isScopeDisabled(config: vscode.WorkspaceConfiguration): boolean { + const enable = config.get("enable") ?? null; + const enablePaths = config.get("enablePaths") ?? null; + if (enablePaths && enablePaths.length == 0) { + return true; + } + return enable === false && enablePaths == null; + } + const workspaceFolders = vscode.workspace.workspaceFolders ?? []; + if (workspaceFolders.length == 0) { + return isScopeDisabled(vscode.workspace.getConfiguration(EXTENSION_NS)); + } + return workspaceFolders.map((f) => + vscode.workspace.getConfiguration(EXTENSION_NS, f) + ).every(isScopeDisabled); +}