Microsoft/monaco-editor

[Bug] Programmatic update of a model doesn't remove error markers

Open

#3 202 ouverte le 19 juil. 2022

Voir sur GitHub
 (1 commentaire) (1 réaction) (0 assignés)JavaScript (1 283 forks)batch import
bughelp wantedtypescripttypescript-multifile

Métriques du dépôt

Stars
 (14 836 stars)
Métriques de merge PR
 (Merge moyen 6h 26m) (15 PRs mergées en 30 j)

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?

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

  1. Simply run the above.
  2. Wait a couple of seconds (note the output in the console).
  3. 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

Guide contributeur