diff --git a/editors/vscode/client/tools/linter.ts b/editors/vscode/client/tools/linter.ts index e839eae6fc431..5ac3f408f044a 100644 --- a/editors/vscode/client/tools/linter.ts +++ b/editors/vscode/client/tools/linter.ts @@ -263,6 +263,9 @@ export default class LinterTool implements ToolInterface { statusBarItemHandler: StatusBarItemHandler, ): Promise { this.updateStatusBar(statusBarItemHandler, configService.vsCodeConfig.enable); + if (event.affectsConfiguration(`${ConfigService.namespace}.enable`)) { + await this.toggleClient(configService); // update the client state + } if (this.client === undefined) { return; diff --git a/editors/vscode/fixtures/changing_enable/debugger.js b/editors/vscode/fixtures/changing_enable/debugger.js new file mode 100644 index 0000000000000..eab74692130a6 --- /dev/null +++ b/editors/vscode/fixtures/changing_enable/debugger.js @@ -0,0 +1 @@ +debugger; diff --git a/editors/vscode/tests/code_actions.spec.ts b/editors/vscode/tests/code_actions.spec.ts index 7e54446e19ee6..f71bb7bbcc826 100644 --- a/editors/vscode/tests/code_actions.spec.ts +++ b/editors/vscode/tests/code_actions.spec.ts @@ -43,6 +43,7 @@ suite('code actions', () => { // flaky test for multi workspace mode testSingleFolderMode('listed code actions', async () => { await loadFixture('debugger'); + await sleep(500); const fileUri = Uri.joinPath(fixturesWorkspaceUri(), 'fixtures', 'debugger.js'); // await window.showTextDocument(fileUri); -- should also work without opening the file diff --git a/editors/vscode/tests/e2e_server_linter.spec.ts b/editors/vscode/tests/e2e_server_linter.spec.ts index 49125061d62e1..84df0c0a07e98 100644 --- a/editors/vscode/tests/e2e_server_linter.spec.ts +++ b/editors/vscode/tests/e2e_server_linter.spec.ts @@ -282,4 +282,23 @@ suite('E2E Server Linter', () => { const secondDiagnostics = await getDiagnostics('index.ts'); strictEqual(secondDiagnostics.length, 1); }); + + testSingleFolderMode('changing oxc.enable will update the client status', async () => { + await loadFixture('changing_enable'); + + const firstDiagnostics = await getDiagnostics('debugger.js'); + strictEqual(firstDiagnostics.length, 1); + + await workspace.getConfiguration('oxc').update('enable', false); + await workspace.saveAll(); + await waitForDiagnosticChange(); + + const secondDiagnostics = await getDiagnostics('debugger.js'); + strictEqual(secondDiagnostics.length, 0); + + // enable it for other tests + await workspace.getConfiguration('oxc').update('enable', true); + await workspace.saveAll(); + await sleep(500); + }) });