From e78304ef8bdf9db44cead941107212068fbadc89 Mon Sep 17 00:00:00 2001 From: Sysix Date: Fri, 15 Nov 2024 18:54:37 +0100 Subject: [PATCH 1/2] fix(editor): reset workspace configuration after change --- editors/vscode/client/config.ts | 34 +++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/editors/vscode/client/config.ts b/editors/vscode/client/config.ts index ba553afb13a91..d47eab6c61f08 100644 --- a/editors/vscode/client/config.ts +++ b/editors/vscode/client/config.ts @@ -4,11 +4,11 @@ import { IDisposable } from './types'; export class ConfigService implements Config, IDisposable { private static readonly _namespace = 'oxc'; private readonly _disposables: IDisposable[] = []; - private _inner: WorkspaceConfiguration; - private _runTrigger: Trigger; - private _enable: boolean; - private _trace: TraceLevel; - private _configPath: string; + private _inner!: WorkspaceConfiguration; + private _runTrigger!: Trigger; + private _enable!: boolean; + private _trace!: TraceLevel; + private _configPath!: string; private _binPath: string | undefined; public onConfigChange: @@ -16,12 +16,7 @@ export class ConfigService implements Config, IDisposable { | undefined; constructor() { - this._inner = workspace.getConfiguration(ConfigService._namespace); - this._runTrigger = this._inner.get('lint.run') || 'onType'; - this._enable = this._inner.get('enable') ?? true; - this._trace = this._inner.get('trace.server') || 'off'; - this._configPath = this._inner.get('configPath') || '.eslintrc'; - this._binPath = this._inner.get('path.server'); + this.setSettingsFromWorkspace(); this.onConfigChange = undefined; const disposeChangeListener = workspace.onDidChangeConfiguration( @@ -30,6 +25,17 @@ export class ConfigService implements Config, IDisposable { this._disposables.push(disposeChangeListener); } + + private setSettingsFromWorkspace(): void { + this._inner = workspace.getConfiguration(ConfigService._namespace); + + this._runTrigger = this._inner.get('lint.run') || 'onType'; + this._enable = this._inner.get('enable') ?? true; + this._trace = this._inner.get('trace.server') || 'off'; + this._configPath = this._inner.get('configPath') || '.eslintrc'; + this._binPath = this._inner.get('path.server'); + } + get runTrigger(): Trigger { return this._runTrigger; } @@ -87,11 +93,7 @@ export class ConfigService implements Config, IDisposable { private onVscodeConfigChange(event: ConfigurationChangeEvent): void { if (event.affectsConfiguration(ConfigService._namespace)) { - this._runTrigger = this._inner.get('lint.run') || 'onType'; - this._enable = this._inner.get('enable') ?? true; - this._trace = this._inner.get('trace.server') || 'off'; - this._configPath = this._inner.get('configPath') || '.eslintrc'; - this._binPath = this._inner.get('path.server'); + this.setSettingsFromWorkspace(); this.onConfigChange?.call(this, event); } } From 7145486abda68e8d23896a37f35d31c123c01dd0 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Fri, 15 Nov 2024 17:58:09 +0000 Subject: [PATCH 2/2] [autofix.ci] apply automated fixes --- editors/vscode/client/config.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/editors/vscode/client/config.ts b/editors/vscode/client/config.ts index d47eab6c61f08..d2eabe94ec753 100644 --- a/editors/vscode/client/config.ts +++ b/editors/vscode/client/config.ts @@ -25,7 +25,6 @@ export class ConfigService implements Config, IDisposable { this._disposables.push(disposeChangeListener); } - private setSettingsFromWorkspace(): void { this._inner = workspace.getConfiguration(ConfigService._namespace);