Skip to content

Commit

Permalink
fix: don't spawn the language server if explicitly disabled settings (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
nayeemrmn authored Apr 26, 2024
1 parent 2470c5e commit 3b25415
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions client/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ export function startLanguageServer(
}
extensionContext.clientSubscriptions = [];

if (isDenoDisabledCompletely()) {
return;
}

// Start a new language server
const command = await getDenoCommandPath();
if (command == null) {
Expand Down Expand Up @@ -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<boolean | null>("enable") ?? null;
const enablePaths = config.get<string[] | null>("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);
}

0 comments on commit 3b25415

Please sign in to comment.