Restore ability to change options after loading

This commit is contained in:
Patrick Shipe 2021-09-14 13:37:14 -06:00
parent 8d278d3d19
commit 7a96d822b1

View file

@ -13,18 +13,27 @@ export function createWorkerManager(
let client: Promise<YAMLWorker>;
let lastUsedTime = 0;
const stopWorker = (): void => {
if (worker) {
worker.dispose();
worker = undefined;
}
client = undefined;
};
setInterval(() => {
if (!worker) {
return;
}
const timePassedSinceLastUsed = Date.now() - lastUsedTime;
if (timePassedSinceLastUsed > STOP_WHEN_IDLE_FOR) {
worker.dispose();
worker = undefined;
client = undefined;
stopWorker();
}
}, 30 * 1000);
// This is necessary to have updated language options take effect (e.g. schema changes)
defaults.onDidChange(() => stopWorker());
const getClient = (): Promise<YAMLWorker> => {
lastUsedTime = Date.now();