Skip to content

Commit

Permalink
chore: migrate config settings to workspaceState
Browse files Browse the repository at this point in the history
  • Loading branch information
mxschmitt committed May 16, 2024
1 parent ed284ee commit c9e9508
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export class Extension implements RunHooks {
},
});

this._settingsModel = new SettingsModel(vscode);
this._settingsModel = new SettingsModel(vscode, context);
this._models = new TestModelCollection(vscode, context);
this._reusedBrowser = new ReusedBrowser(this._vscode, this._settingsModel, this._envProvider.bind(this));
this._traceViewer = new TraceViewer(this._vscode, this._settingsModel, this._envProvider.bind(this));
Expand Down
14 changes: 13 additions & 1 deletion src/settingsModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,16 @@ export type WorkspaceSettings = {
export class SettingsModel extends DisposableBase {
private _vscode: vscodeTypes.VSCode;
private _settings = new Map<string, Setting<any>>();
private _context: vscodeTypes.ExtensionContext;
readonly onChange: vscodeTypes.Event<void>;
private _onChange: vscodeTypes.EventEmitter<void>;
showBrowser: Setting<boolean>;
showTrace: Setting<boolean>;

constructor(vscode: vscodeTypes.VSCode) {
constructor(vscode: vscodeTypes.VSCode, context: vscodeTypes.ExtensionContext) {
super();
this._vscode = vscode;
this._context = context;
this._onChange = new vscode.EventEmitter();
this.onChange = this._onChange.event;

Expand All @@ -58,6 +60,16 @@ export class SettingsModel extends DisposableBase {
if (enabled && this.showBrowser.get())
this.showBrowser.set(false);
});

this._modernize();
}

private _modernize() {
const workspaceSettings = this._vscode.workspace.getConfiguration('playwright').get('workspaceSettings') as any;
if (workspaceSettings?.configs) {
this._context.workspaceState.update('pw.workspace-settings', { configs: workspaceSettings.configs });
this._vscode.workspace.getConfiguration('playwright').update('workspaceSettings', undefined);
}
}

private _createSetting<T>(settingName: string): Setting<T> {
Expand Down

0 comments on commit c9e9508

Please sign in to comment.