mirror of
https://github.com/danbulant/monaco-yaml
synced 2026-05-19 04:08:48 +00:00
Merge pull request #109 from patrickshipe/restore-options-updates
Restore ability to change options after loading
This commit is contained in:
commit
65e91a1d43
1 changed files with 12 additions and 3 deletions
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue