fix(ui): load Monaco basic language tokenizers correctly
This commit is contained in:
@@ -118,8 +118,10 @@ function getContributionModuleId(languageId: string): string | null {
|
|||||||
if (id === "html") return "vs/language/html/monaco.contribution"
|
if (id === "html") return "vs/language/html/monaco.contribution"
|
||||||
|
|
||||||
// Basic tokenizers
|
// Basic tokenizers
|
||||||
if (id === "toml") return "vs/basic-languages/toml/toml.contribution"
|
// Monaco's `min/vs/basic-languages/<id>/` ships `<id>.js` (no `*.contribution.js`).
|
||||||
return `vs/basic-languages/${id}/${id}.contribution`
|
// Loading the tokenizer module is enough; it registers itself with the language service.
|
||||||
|
if (id === "toml") return "vs/basic-languages/toml/toml"
|
||||||
|
return `vs/basic-languages/${id}/${id}`
|
||||||
}
|
}
|
||||||
|
|
||||||
const loadedContributions = new Set<string>()
|
const loadedContributions = new Set<string>()
|
||||||
@@ -134,12 +136,14 @@ export async function ensureMonacoLanguageLoaded(languageId: string): Promise<vo
|
|||||||
if (pending) return pending
|
if (pending) return pending
|
||||||
|
|
||||||
const task = (async () => {
|
const task = (async () => {
|
||||||
|
let loaded = false
|
||||||
try {
|
try {
|
||||||
await requireAsync([moduleId])
|
await requireAsync([moduleId])
|
||||||
|
loaded = true
|
||||||
} catch {
|
} catch {
|
||||||
// ignore
|
// ignore
|
||||||
} finally {
|
} finally {
|
||||||
loadedContributions.add(moduleId)
|
if (loaded) loadedContributions.add(moduleId)
|
||||||
pendingContributions.delete(moduleId)
|
pendingContributions.delete(moduleId)
|
||||||
}
|
}
|
||||||
})()
|
})()
|
||||||
|
|||||||
Reference in New Issue
Block a user