Skip to content

Commit 5a2832d

Browse files
fix(editor): stop client when delete .oxlintrc.json with oxc.requireConfig (#14897)
Closes #14896 by extending watcher detect file deleting and stop client --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent bd74603 commit 5a2832d

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

editors/vscode/client/extension.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,15 +331,25 @@ function updateStatsBar(
331331
}
332332

333333
function generateActivatorByConfig(config: VSCodeConfig, context: ExtensionContext): void {
334-
const watcher = workspace.createFileSystemWatcher('**/.oxlintrc.json', false, true, true);
334+
const watcher = workspace.createFileSystemWatcher('**/.oxlintrc.json', false, true, !config.requireConfig);
335335
watcher.onDidCreate(async () => {
336-
watcher.dispose();
337336
allowedToStartServer = true;
338337
updateStatsBar(context, config.enable);
339338
if (client && !client.isRunning() && config.enable) {
340339
await client.start();
341340
}
342341
});
343342

343+
watcher.onDidDelete(async () => {
344+
// only can be called when config.requireConfig
345+
allowedToStartServer = (await workspace.findFiles(`**/.oxlintrc.json`, '**/node_modules/**', 1)).length > 0;
346+
if (!allowedToStartServer) {
347+
updateStatsBar(context, false);
348+
if (client && client.isRunning()) {
349+
await client.stop();
350+
}
351+
}
352+
});
353+
344354
context.subscriptions.push(watcher);
345355
}

0 commit comments

Comments
 (0)