Skip to content

Commit f97f75c

Browse files
Restore original settings after disabling ISE mode (#4308)
We were previously setting them to `undefined` which mostly worked, unless the user had customized the setting. This was most apparent and commonly done with `colorTheme`. Now we save when we enable, and restore to that value. Note that will only work for the original session, but it does allow the user to test ISE mode out without repercussions. We could probably save the settings into the global storage context, but that might get hairy!
1 parent 00502b6 commit f97f75c

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/features/ISECompatibility.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export class ISECompatibilityFeature implements vscode.Disposable {
2828

2929
private _commandRegistrations: vscode.Disposable[] = [];
3030
private _iseModeEnabled: boolean;
31+
private _originalSettings: Record<string, boolean | string | undefined> = {};
3132

3233
constructor() {
3334
// TODO: This test isn't great.
@@ -50,7 +51,9 @@ export class ISECompatibilityFeature implements vscode.Disposable {
5051
this._iseModeEnabled = true;
5152
for (const iseSetting of ISECompatibilityFeature.settings) {
5253
try {
53-
await vscode.workspace.getConfiguration(iseSetting.path).update(iseSetting.name, iseSetting.value, true);
54+
const config = vscode.workspace.getConfiguration(iseSetting.path);
55+
this._originalSettings[iseSetting.path + iseSetting.name] = config.get(iseSetting.name);
56+
await config.update(iseSetting.name, iseSetting.value, true);
5457
} catch {
5558
// The `update` call can fail if the setting doesn't exist. This
5659
// happens when the extension runs in Azure Data Studio, which
@@ -72,9 +75,10 @@ export class ISECompatibilityFeature implements vscode.Disposable {
7275
private async DisableISEMode() {
7376
this._iseModeEnabled = false;
7477
for (const iseSetting of ISECompatibilityFeature.settings) {
75-
const currently = vscode.workspace.getConfiguration(iseSetting.path).get<string | boolean>(iseSetting.name);
78+
const config = vscode.workspace.getConfiguration(iseSetting.path);
79+
const currently = config.get(iseSetting.name);
7680
if (currently === iseSetting.value) {
77-
await vscode.workspace.getConfiguration(iseSetting.path).update(iseSetting.name, undefined, true);
81+
await config.update(iseSetting.name, this._originalSettings[iseSetting.path + iseSetting.name], true);
7882
}
7983
}
8084
}

0 commit comments

Comments
 (0)