Skip to content

Commit 08c775e

Browse files
authored
Merge pull request #241 from sourcery-ai/ben/sou-2022-feat-add-a-settings-cog-to-the-coding-assistant
feat: handle configuration changes from the app
2 parents c5710e4 + b2dc830 commit 08c775e

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/chat.ts

+18
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export type ExtensionMessage =
2525
request: "openLink";
2626
linkType: "url" | "file" | "directory";
2727
link: string;
28+
documentRange: DocumentRange | null;
2829
}
2930
| {
3031
target: "extension";
@@ -35,6 +36,14 @@ export type ExtensionMessage =
3536
target: "extension";
3637
request: "insertAtCursor";
3738
content: string;
39+
}
40+
| {
41+
target: "extension";
42+
request: "updateConfiguration";
43+
section: "sourcery.codeLens";
44+
value: boolean;
45+
// https://code.visualstudio.com/api/references/vscode-api#ConfigurationTarget
46+
configurationTarget: vscode.ConfigurationTarget;
3847
};
3948

4049
type LanguageServerMessage = {
@@ -107,6 +116,15 @@ export class ChatProvider implements vscode.WebviewViewProvider {
107116
this.handleInsertAtCursorRequest(message);
108117
break;
109118
}
119+
case "updateConfiguration": {
120+
await vscode.workspace
121+
.getConfiguration()
122+
.update(
123+
message.section,
124+
message.value,
125+
message.configurationTarget
126+
);
127+
}
110128
}
111129
}
112130
}

src/extension.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,11 @@ function registerCommands(
209209
commands.registerCommand("sourcery.chat.toggleCodeLens", () => {
210210
const config = vscode.workspace.getConfiguration();
211211
const currentValue = config.get("sourcery.codeLens");
212-
config.update("sourcery.codeLens", !currentValue);
212+
config.update(
213+
"sourcery.codeLens",
214+
!currentValue,
215+
vscode.ConfigurationTarget.Global
216+
);
213217
})
214218
);
215219

0 commit comments

Comments
 (0)