diff --git a/src/chat.ts b/src/chat.ts index 8a70f2e5..b266b30f 100644 --- a/src/chat.ts +++ b/src/chat.ts @@ -25,6 +25,7 @@ export type ExtensionMessage = request: "openLink"; linkType: "url" | "file" | "directory"; link: string; + documentRange: DocumentRange | null; } | { target: "extension"; @@ -35,6 +36,14 @@ export type ExtensionMessage = target: "extension"; request: "insertAtCursor"; content: string; + } + | { + target: "extension"; + request: "updateConfiguration"; + section: "sourcery.codeLens"; + value: boolean; + // https://code.visualstudio.com/api/references/vscode-api#ConfigurationTarget + configurationTarget: vscode.ConfigurationTarget; }; type LanguageServerMessage = { @@ -107,6 +116,15 @@ export class ChatProvider implements vscode.WebviewViewProvider { this.handleInsertAtCursorRequest(message); break; } + case "updateConfiguration": { + await vscode.workspace + .getConfiguration() + .update( + message.section, + message.value, + message.configurationTarget + ); + } } } } diff --git a/src/extension.ts b/src/extension.ts index 48d266a0..d9b95831 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -209,7 +209,11 @@ function registerCommands( commands.registerCommand("sourcery.chat.toggleCodeLens", () => { const config = vscode.workspace.getConfiguration(); const currentValue = config.get("sourcery.codeLens"); - config.update("sourcery.codeLens", !currentValue); + config.update( + "sourcery.codeLens", + !currentValue, + vscode.ConfigurationTarget.Global + ); }) );