Microsoft/monaco-editor

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

Open

#3,202 opened on 2022年7月19日

GitHub で見る
 (1 comment) (1 reaction) (0 assignees)JavaScript (1,283 forks)batch import
bughelp wantedtypescripttypescript-multifile

Repository metrics

Stars
 (14,836 stars)
PR merge metrics
 (平均マージ 6h 26m) (30d で 15 merged PRs)

説明

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

コントリビューターガイド