Skip to content

Commit 7af4583

Browse files
committed
feat(vscode): add option to control extension activation per scope
Add new `robotcode.disableExtension` configuration setting that allows users to disable or enable the RobotCode extension at any scope level. With resource scope, users can: - Disable the extension globally (user settings) and enable it for specific workspaces or folders - Disable the extension for a workspace and enable it for specific folders within - Disable the extension only for specific folders in multi-root workspaces This is useful in: - Large workspaces where RobotCode is not needed everywhere - Multi-root workspaces with mixed project types - Environments where users want opt-in rather than opt-out behavior Changes: - Add `disableExtension` boolean setting with resource scope - Skip language client creation when extension is disabled - Disable test explorer for disabled workspace folders - Add "Disable" option to Python environment selection dialog - React to `disableExtension` configuration changes for restart closes #527
1 parent 5edb90c commit 7af4583

File tree

4 files changed

+28
-5
lines changed

4 files changed

+28
-5
lines changed

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,12 @@
684684
"id": "robotcode.general",
685685
"type": "object",
686686
"properties": {
687+
"robotcode.disableExtension": {
688+
"type": "boolean",
689+
"default": false,
690+
"markdownDescription": "Disables the RobotCode extension for the workspace or folder.\n\nThis is useful in large workspaces or multi root workspaces where you do not want to use RobotCode everywhere.",
691+
"scope": "resource"
692+
},
687693
"robotcode.extraArgs": {
688694
"type": "array",
689695
"default": [],

vscode-client/extension/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,13 @@ export async function activateAsync(context: vscode.ExtensionContext): Promise<v
138138
"robotcode.documentationServer",
139139
"robotcode.completion",
140140
"robotcode.inlayHints",
141+
"robotcode.disableExtension",
141142
]) {
142143
for (const ws of vscode.workspace.workspaceFolders ?? []) {
143-
if (languageClientManger.clients.has(ws.uri.toString()))
144-
if (event.affectsConfiguration(s, ws)) {
145-
affectedFolders.add(ws.uri);
146-
}
144+
// if (languageClientManger.clients.has(ws.uri.toString()))
145+
if (event.affectsConfiguration(s, ws)) {
146+
affectedFolders.add(ws.uri);
147+
}
147148
}
148149
}
149150

vscode-client/extension/languageclientsmanger.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,9 +381,10 @@ export class LanguageClientsManager {
381381
detail:
382382
"Install `robotframework` version 4.1 or higher manually in the current environment, then restart the language server",
383383
},
384-
{ id: "ignore", label: "Ignore", detail: "Ignore this at the moment" },
385384
]
386385
: []),
386+
{ id: "ignore", label: "Ignore", detail: "Ignore this at the moment" },
387+
{ id: "disable", label: "Disable", detail: "Disable the RobotCode extension for this workspace or folder" },
387388
],
388389
{ title: title, placeHolder: "Choose an option...", ignoreFocusOut: true },
389390
this.selectPythonEnvironmentCancelTokenSource.token,
@@ -398,6 +399,12 @@ export class LanguageClientsManager {
398399
break;
399400
case "retry":
400401
return;
402+
case "disable":
403+
if (folder !== undefined) {
404+
const config = vscode.workspace.getConfiguration(CONFIG_SECTION, folder);
405+
await config.update("disableExtension", true, vscode.ConfigurationTarget.WorkspaceFolder);
406+
}
407+
break;
401408
default:
402409
if (!showRetry) return;
403410
}
@@ -576,6 +583,10 @@ export class LanguageClientsManager {
576583

577584
if (!workspaceFolder) return undefined;
578585

586+
if (vscode.workspace.getConfiguration(CONFIG_SECTION, workspaceFolder).get<boolean>("disableExtension")) {
587+
return undefined;
588+
}
589+
579590
let result = this.clients.get(workspaceFolder.uri.toString());
580591

581592
if (result) return result;

vscode-client/extension/testcontrollermanager.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,12 @@ export class TestControllerManager {
882882

883883
// eslint-disable-next-line class-methods-use-this
884884
private isTestExplorerEnabledForWorkspace(workspace: vscode.WorkspaceFolder): boolean {
885+
if (vscode.workspace.getConfiguration(CONFIG_SECTION, workspace).get<boolean>("disableExtension")) {
886+
return false;
887+
}
888+
885889
const result = vscode.workspace.getConfiguration(CONFIG_SECTION, workspace).get<boolean>("testExplorer.enabled");
890+
886891
return result === undefined || result;
887892
}
888893

0 commit comments

Comments
 (0)