Microsoft/monaco-editor
View on GitHub[Bug] Programmatic update of a model doesn't remove error markers
Open
#3,202 opened on Jul 19, 2022
bughelp wantedtypescripttypescript-multifile
Repository metrics
- Stars
- (14,836 stars)
- PR merge metrics
- (Avg merge 6h 26m) (15 merged PRs in 30d)
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 Code
monaco.languages.typescript.typescriptDefaults.setCompilerOptions({
target: monaco.languages.typescript.ScriptTarget.ES2020,
})
monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
noSemanticValidation: false,
noSyntaxValidation: false,
});
const fileA = `import { Test } from "./B";
console.log(Test.func());`;
const fileB = `export class Test {}`;
const modelA = monaco.editor.createModel(fileA, "typescript", monaco.Uri.parse("file:///A.ts"));
const modelB = monaco.editor.createModel(fileB, "typescript", monaco.Uri.parse("file:///B.ts"));
const editor = monaco.editor.create(document.getElementById('container'), {
model: modelA,
language: "typescript"
});
const showDiags = () => {
monaco.languages.typescript.getTypeScriptWorker()
.then(f => f())
.then(worker => worker.getSemanticDiagnostics("file:///A.ts"))
.then(diags => {
console.info(diags);
console.info(modelA.getAllDecorations());
});
};
setTimeout(() => {
modelB.setValue(`export class Test {
static func() {
return 5;
}
`);
monaco.languages.typescript.typescriptDefaults.setEagerModelSync(true);
setTimeout(showDiags, 1000);
}, 1000);
Reproduction Steps
- Simply run the above.
- Wait a couple of seconds (note the output in the console).
- Add a newline at the end of the file.
Actual (Problematic) Behavior
When updating modelB programmatically, semantic diagnostics are properly updated for modelA to reflect the lack of a missing function, but the markers for the original error remain in modelA. Editing modelA (e.g., adding a newline) removes the error marker.
Expected Behavior
Programmatic update of modelB to resolve a type error in modelA should result in the removal of error markers in modelA
Additional Context
No response