mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 19:42:56 +01:00
Fixes microsoft/monaco-editor#1998: make sure to always increase the version number
This commit is contained in:
parent
0ac03ae5cd
commit
ee6d058e66
1 changed files with 14 additions and 1 deletions
|
|
@ -448,6 +448,7 @@ class LanguageServiceDefaultsImpl implements LanguageServiceDefaults {
|
|||
private _onDidExtraLibsChange = new Emitter<void>();
|
||||
|
||||
private _extraLibs: IExtraLibs;
|
||||
private _removedExtraLibs: { [path: string]: number };
|
||||
private _eagerModelSync: boolean;
|
||||
private _compilerOptions!: CompilerOptions;
|
||||
private _diagnosticsOptions!: DiagnosticsOptions;
|
||||
|
|
@ -460,6 +461,7 @@ class LanguageServiceDefaultsImpl implements LanguageServiceDefaults {
|
|||
workerOptions: WorkerOptions
|
||||
) {
|
||||
this._extraLibs = Object.create(null);
|
||||
this._removedExtraLibs = Object.create(null);
|
||||
this._eagerModelSync = false;
|
||||
this.setCompilerOptions(compilerOptions);
|
||||
this.setDiagnosticsOptions(diagnosticsOptions);
|
||||
|
|
@ -499,6 +501,9 @@ class LanguageServiceDefaultsImpl implements LanguageServiceDefaults {
|
|||
}
|
||||
|
||||
let myVersion = 1;
|
||||
if (this._removedExtraLibs[filePath]) {
|
||||
myVersion = this._removedExtraLibs[filePath] + 1;
|
||||
}
|
||||
if (this._extraLibs[filePath]) {
|
||||
myVersion = this._extraLibs[filePath].version + 1;
|
||||
}
|
||||
|
|
@ -520,12 +525,16 @@ class LanguageServiceDefaultsImpl implements LanguageServiceDefaults {
|
|||
}
|
||||
|
||||
delete this._extraLibs[filePath];
|
||||
this._removedExtraLibs[filePath] = myVersion;
|
||||
this._fireOnDidExtraLibsChangeSoon();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
setExtraLibs(libs: { content: string; filePath?: string }[]): void {
|
||||
for (const filePath in this._extraLibs) {
|
||||
this._removedExtraLibs[filePath] = this._extraLibs[filePath].version;
|
||||
}
|
||||
// clear out everything
|
||||
this._extraLibs = Object.create(null);
|
||||
|
||||
|
|
@ -534,9 +543,13 @@ class LanguageServiceDefaultsImpl implements LanguageServiceDefaults {
|
|||
const filePath =
|
||||
lib.filePath || `ts:extralib-${Math.random().toString(36).substring(2, 15)}`;
|
||||
const content = lib.content;
|
||||
let myVersion = 1;
|
||||
if (this._removedExtraLibs[filePath]) {
|
||||
myVersion = this._removedExtraLibs[filePath] + 1;
|
||||
}
|
||||
this._extraLibs[filePath] = {
|
||||
content: content,
|
||||
version: 1
|
||||
version: myVersion
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue