mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 11:35:40 +01:00
Rework based on PR feedback for schemas
This commit is contained in:
parent
f0c242d083
commit
65058029d8
1 changed files with 24 additions and 11 deletions
|
|
@ -69,26 +69,39 @@ export class TypeScriptWorker implements ts.LanguageServiceHost, ITypeScriptWork
|
||||||
const models = allModels
|
const models = allModels
|
||||||
// remove default libs
|
// remove default libs
|
||||||
.filter((model) => !fileNameIsLib(model.uri))
|
.filter((model) => !fileNameIsLib(model.uri))
|
||||||
// remove extra libs and previously removed libs
|
// remove extra libs
|
||||||
// Note that is is required for all model names to be unique, so
|
|
||||||
// while the logic here depends on the end user not creating extra
|
|
||||||
// libs with conflicting filenames, that is already a requirement.
|
|
||||||
.filter((model) => {
|
.filter((model) => {
|
||||||
const uriAsString = model.uri.toString();
|
const modelUri = model.uri.toString();
|
||||||
// if the extra lib was not given a name, then it gets an autogenerated name prefixed with ts:extralib-
|
if (this._extraLibs[modelUri]) {
|
||||||
if (uriAsString.startsWith('ts:extralib-')) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Otherwise, the prefix will be file:/// and the name will be what the user provided to add/setExtraLibs
|
// Extra libs passed with no schema get a file:/// prefix from the model but not in the _extraLibs map
|
||||||
|
if (
|
||||||
|
modelUri.startsWith('file:///') &&
|
||||||
|
this._extraLibs[modelUri.replace('file:///', '')]?.version
|
||||||
|
) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
})
|
||||||
|
// remove previously removed libs
|
||||||
|
.filter((model) => {
|
||||||
|
const modelUri = model.uri.toString();
|
||||||
if (
|
if (
|
||||||
this._removedExtraLibs.some(
|
this._removedExtraLibs.some(
|
||||||
(removed) =>
|
(removed) => removed.uri === modelUri && removed.version === model.version
|
||||||
`file:///${removed.uri}` === uriAsString && removed.version === model.version
|
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (this._extraLibs[uriAsString.replace(/^file:\/\/\//, '')]?.version === model.version) {
|
// if the extra lib was passed with no schema, it gets a file:/// prefix from the model
|
||||||
|
if (
|
||||||
|
modelUri.startsWith('file:///') &&
|
||||||
|
this._removedExtraLibs.some(
|
||||||
|
(removed) =>
|
||||||
|
removed.uri === modelUri.replace('file:///', '') && removed.version === model.version
|
||||||
|
)
|
||||||
|
) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue