Skip to content

Commit

Permalink
Merge pull request #241 from sourcery-ai/ben/sou-2022-feat-add-a-sett…
Browse files Browse the repository at this point in the history
…ings-cog-to-the-coding-assistant

feat: handle configuration changes from the app
  • Loading branch information
bm424 authored Dec 15, 2023
2 parents c5710e4 + b2dc830 commit 08c775e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
18 changes: 18 additions & 0 deletions src/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export type ExtensionMessage =
request: "openLink";
linkType: "url" | "file" | "directory";
link: string;
documentRange: DocumentRange | null;
}
| {
target: "extension";
Expand All @@ -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 = {
Expand Down Expand Up @@ -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
);
}
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
})
);

Expand Down

0 comments on commit 08c775e

Please sign in to comment.