microsoft / microsoft/monaco-editor
[Bug] Updating extra lib not working after dispose in 0.39.0 version. It is working fine till version 0.28.0
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 46.8k
- Forks
- 4.1k
- Avg merge
- 17h 58m
- Merged PRs (30d)
- 1
Description
Reproducible in vscode.dev or in VS Code Desktop?
- Not reproducible in vscode.dev or VS Code Desktop
Reproducible in the monaco editor playground?
- Not reproducible in the monaco editor playground
Monaco Editor Playground Link
Dynamically adding extra lib is not working on 0.39.0 version. It was working fine till 0.28.0 version.
Below are the play ground link of 0.39.0 and 0.28.0
After playground editors are loaded, please follow the below steps to reproduce the issue:
step1 - Click on Second_injection button.
step2 - Click on Third_injection button.
step3 - Click on First_injection button.
After step3, editor should not show the error for test.descriptionfirst property, because we injected the first library again on button click. But it is still showing the error in 0.39.0 version. Same workflow working fine in 0.28.0 version.
Monaco Editor Playground Code
const value = /* set from `myEditor.getModel()`: */ `function hello() {
alert('Hello world!');
}
var test:Test;
test.descriptionfirst;`;
// Hover on each property to see its docs!
const myEditor = monaco.editor.create(document.getElementById("container"), {
value,
language: "typescript",
automaticLayout: true,
});
var library = "declare class Test { descriptionfirst:string; } ";
let testDisposable1 = monaco.languages.typescript.typescriptDefaults.addExtraLib(library, monaco.Uri.file("test.d.ts").toString());
let testDisposable2 = monaco.languages.typescript.javascriptDefaults.addExtraLib(library, monaco.Uri.file("test.d.ts").toString());
var firstInjectTest = function firstInjectTest() {
testDisposable1.dispose();
testDisposable2.dispose();
let library = "declare class Test { descriptionfirst:string; } ";
testDisposable1 = monaco.languages.typescript.typescriptDefaults.addExtraLib(library, monaco.Uri.file("test.d.ts").toString());
testDisposable2 = monaco.languages.typescript.javascriptDefaults.addExtraLib(library, monaco.Uri.file("test.d.ts").toString());
alert('First library Injection\n LibraryClass: '+library);
}
window['firstInjectTest'] = firstInjectTest;
var secondInjectTest = function secondInjectTest() {
testDisposable1.dispose();
testDisposable2.dispose();
let library = "declare class Test { descriptionsecond:string; } ";
testDisposable1 = monaco.languages.typescript.typescriptDefaults.addExtraLib(library, monaco.Uri.file("test.d.ts").toString());
testDisposable2 = monaco.languages.typescript.javascriptDefaults.addExtraLib(library, monaco.Uri.file("test.d.ts").toString());
alert('Second library Injection \n LibraryClass: '+library);
}
window['secondInjectTest'] = secondInjectTest;
var thirdInjectTest = function thirdInjectTest() {
testDisposable1.dispose();
testDisposable2.dispose();
let library = "declare class Test { descriptionthird:string; } ";
testDisposable1 = monaco.languages.typescript.typescriptDefaults.addExtraLib(library, monaco.Uri.file("test.d.ts").toString());
testDisposable2 = monaco.languages.typescript.javascriptDefaults.addExtraLib(library, monaco.Uri.file("test.d.ts").toString());
alert('Third library Injection \n LibraryClass: '+library);
}
window['thirdInjectTest'] = thirdInjectTest;
// HTML CODE
<br><br>
<input type = "button" value="First_Injection" onclick = "firstInjectTest();" />
<br><br>
<input type = "button" value="Second_Injection" onclick = "secondInjectTest();" />
<br><br>
<input type = "button" value="Third_Injection" onclick = "thirdInjectTest();" />
<div id="container" style="height: 100%"></div>
Reproduction Steps
After playground editors are loaded, please follow the below steps to reproduce the issue:
step1 - Click on Second_injection button.
step2 - Click on Third_injection button.
step3 - Click on First_injection button.
After step3, editor should not show the error for test.descriptionfirst property, because we injected the first library again on First_injection button click. But it is still showing the error in 0.39.0 version. Same workflow working fine in 0.28.0 version.
Actual (Problematic) Behavior
If we dynamically dispose the library and add again with changes, first time it work fine but from the second time it is not working in 0.39.0 version but and I check in earlier version the same workflow was working till 0.28.0 version.
I have mentioned steps to reproduce the issue in Reproduction Steps.
Expected Behavior
It should dynamically dispose the previous library and add changed library and also should show the intelligence for change library even if we repeat the steps multiple times.
After step3, editor should not show the error for test.descriptionfirst property, because we injected the first library again on First_injection button click. But it is still showing the error in 0.39.0 version. Same workflow working fine in 0.28.0 version.
Additional Context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked Monaco Editor Playground reproductions and the shown calls to typescriptDefaults.addExtraLib, javascriptDefaults.addExtraLib, and their disposable objects. Repeat the Second_injection, Third_injection, and First_injection sequence in version 0.39.0, then trace the corresponding extra-library and disposal implementation. Done means repeated disposal and reinjection restores completion and removes the test.descriptionfirst error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100