From 89f05cc5d9a2ff0b8de477867d151c47a657ec36 Mon Sep 17 00:00:00 2001 From: Andy Jordan Date: Tue, 6 Dec 2022 14:42:27 -0800 Subject: [PATCH] Restore original settings after disabling ISE mode 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! --- src/features/ISECompatibility.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/features/ISECompatibility.ts b/src/features/ISECompatibility.ts index 0a4993ca69..e741ed0b0f 100644 --- a/src/features/ISECompatibility.ts +++ b/src/features/ISECompatibility.ts @@ -28,6 +28,7 @@ export class ISECompatibilityFeature implements vscode.Disposable { private _commandRegistrations: vscode.Disposable[] = []; private _iseModeEnabled: boolean; + private _originalSettings: Record = {}; constructor() { // TODO: This test isn't great. @@ -50,7 +51,9 @@ export class ISECompatibilityFeature implements vscode.Disposable { this._iseModeEnabled = true; for (const iseSetting of ISECompatibilityFeature.settings) { try { - await vscode.workspace.getConfiguration(iseSetting.path).update(iseSetting.name, iseSetting.value, true); + const config = vscode.workspace.getConfiguration(iseSetting.path); + this._originalSettings[iseSetting.path + iseSetting.name] = config.get(iseSetting.name); + await config.update(iseSetting.name, iseSetting.value, true); } catch { // The `update` call can fail if the setting doesn't exist. This // happens when the extension runs in Azure Data Studio, which @@ -72,9 +75,10 @@ export class ISECompatibilityFeature implements vscode.Disposable { private async DisableISEMode() { this._iseModeEnabled = false; for (const iseSetting of ISECompatibilityFeature.settings) { - const currently = vscode.workspace.getConfiguration(iseSetting.path).get(iseSetting.name); + const config = vscode.workspace.getConfiguration(iseSetting.path); + const currently = config.get(iseSetting.name); if (currently === iseSetting.value) { - await vscode.workspace.getConfiguration(iseSetting.path).update(iseSetting.name, undefined, true); + await config.update(iseSetting.name, this._originalSettings[iseSetting.path + iseSetting.name], true); } } }