mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 12:19:15 +00:00
fix(editor): reload workspace configuration after change (#7302)
after changing `settings.json`, the changes whould not to updated internally. With this PR the updated values get passed to the language-server. 🥳 probably closes https://github.com/oxc-project/backlog/issues/132 because we also support the oxlint config --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
1cbc624a8b
commit
ba0b2ff856
1 changed files with 17 additions and 16 deletions
|
|
@ -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<Trigger>('lint.run') || 'onType';
|
||||
this._enable = this._inner.get<boolean>('enable') ?? true;
|
||||
this._trace = this._inner.get<TraceLevel>('trace.server') || 'off';
|
||||
this._configPath = this._inner.get<string>('configPath') || '.eslintrc';
|
||||
this._binPath = this._inner.get<string>('path.server');
|
||||
this.setSettingsFromWorkspace();
|
||||
this.onConfigChange = undefined;
|
||||
|
||||
const disposeChangeListener = workspace.onDidChangeConfiguration(
|
||||
|
|
@ -30,6 +25,16 @@ export class ConfigService implements Config, IDisposable {
|
|||
this._disposables.push(disposeChangeListener);
|
||||
}
|
||||
|
||||
private setSettingsFromWorkspace(): void {
|
||||
this._inner = workspace.getConfiguration(ConfigService._namespace);
|
||||
|
||||
this._runTrigger = this._inner.get<Trigger>('lint.run') || 'onType';
|
||||
this._enable = this._inner.get<boolean>('enable') ?? true;
|
||||
this._trace = this._inner.get<TraceLevel>('trace.server') || 'off';
|
||||
this._configPath = this._inner.get<string>('configPath') || '.eslintrc';
|
||||
this._binPath = this._inner.get<string>('path.server');
|
||||
}
|
||||
|
||||
get runTrigger(): Trigger {
|
||||
return this._runTrigger;
|
||||
}
|
||||
|
|
@ -87,11 +92,7 @@ export class ConfigService implements Config, IDisposable {
|
|||
|
||||
private onVscodeConfigChange(event: ConfigurationChangeEvent): void {
|
||||
if (event.affectsConfiguration(ConfigService._namespace)) {
|
||||
this._runTrigger = this._inner.get<Trigger>('lint.run') || 'onType';
|
||||
this._enable = this._inner.get<boolean>('enable') ?? true;
|
||||
this._trace = this._inner.get<TraceLevel>('trace.server') || 'off';
|
||||
this._configPath = this._inner.get<string>('configPath') || '.eslintrc';
|
||||
this._binPath = this._inner.get<string>('path.server');
|
||||
this.setSettingsFromWorkspace();
|
||||
this.onConfigChange?.call(this, event);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue