mirror of
https://github.com/danbulant/monaco-yaml
synced 2026-07-06 19:40:55 +00:00
Restore ability to change options after loading
This commit is contained in:
parent
8d278d3d19
commit
7a96d822b1
1 changed files with 12 additions and 3 deletions
|
|
@ -13,18 +13,27 @@ export function createWorkerManager(
|
||||||
let client: Promise<YAMLWorker>;
|
let client: Promise<YAMLWorker>;
|
||||||
let lastUsedTime = 0;
|
let lastUsedTime = 0;
|
||||||
|
|
||||||
|
const stopWorker = (): void => {
|
||||||
|
if (worker) {
|
||||||
|
worker.dispose();
|
||||||
|
worker = undefined;
|
||||||
|
}
|
||||||
|
client = undefined;
|
||||||
|
};
|
||||||
|
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
if (!worker) {
|
if (!worker) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const timePassedSinceLastUsed = Date.now() - lastUsedTime;
|
const timePassedSinceLastUsed = Date.now() - lastUsedTime;
|
||||||
if (timePassedSinceLastUsed > STOP_WHEN_IDLE_FOR) {
|
if (timePassedSinceLastUsed > STOP_WHEN_IDLE_FOR) {
|
||||||
worker.dispose();
|
stopWorker();
|
||||||
worker = undefined;
|
|
||||||
client = undefined;
|
|
||||||
}
|
}
|
||||||
}, 30 * 1000);
|
}, 30 * 1000);
|
||||||
|
|
||||||
|
// This is necessary to have updated language options take effect (e.g. schema changes)
|
||||||
|
defaults.onDidChange(() => stopWorker());
|
||||||
|
|
||||||
const getClient = (): Promise<YAMLWorker> => {
|
const getClient = (): Promise<YAMLWorker> => {
|
||||||
lastUsedTime = Date.now();
|
lastUsedTime = Date.now();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue