Skip to content

Restore original settings after disabling ISE mode #4308

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/features/ISECompatibility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export class ISECompatibilityFeature implements vscode.Disposable {

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

constructor() {
// TODO: This test isn't great.
Expand All @@ -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
Expand All @@ -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<string | boolean>(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);
}
}
}
Expand Down