diff --git a/src/monaco/env.ts b/src/monaco/env.ts index accc8c24..54183614 100644 --- a/src/monaco/env.ts +++ b/src/monaco/env.ts @@ -8,6 +8,7 @@ import type { CreateData } from './vue.worker' import vueWorker from './vue.worker?worker' import * as languageConfigs from './language-configs' import type { LanguageService } from '@vue/language-service' +import { debounce } from '../utils' let initted = false export function initMonaco(store: Store) { @@ -155,7 +156,12 @@ export function loadMonacoEnv(store: Store) { languages.setLanguageConfiguration('typescript', languageConfigs.ts) languages.setLanguageConfiguration('css', languageConfigs.css) - store.reloadLanguageTools = () => reloadLanguageTools(store) + let languageToolsPromise: Promise | undefined + store.reloadLanguageTools = debounce(async () => { + ;(languageToolsPromise ||= reloadLanguageTools(store)).finally(() => { + languageToolsPromise = undefined + }) + }, 250) languages.onLanguage('vue', () => store.reloadLanguageTools!()) // Support for go to definition