getModelMarkers not working to get list of errors

See original GitHub issue

I’m trying to get list of validation errors generated by monaco editor and do some custom operations, my current implementation is working but it’s not an ideal solution, I’m looking for something like where i can use getModelMarkers instead of setModelMarkers which i’m using currently shown below.

updateEditorText(val) {
            const setModelMarkers = monaco.editor.setModelMarkers;
            monaco.editor.setModelMarkers = (model, owner, markers) => {
                debugger;
                setModelMarkers.call(monaco.editor, model, owner, markers);
                if (markers.length === 0) {
                    this.containsValidationErrors = false;
                    this.setJsonText(val);
                } else {
                    this.containsValidationErrors = true;
                }
            };
        },

I found we can do like

monaco.editor.getModelMarkers({}).map(m => m.message).join(', ')

but when i try to use it in my function above instead of setModelMarkers it does’nt work and throws errors. Please suggest How can i use monaco.editor.getModelMarkers

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
WarcraftYaxcommented, Jun 10, 2018

Fixed my issue by grabbing the editor off of the window rather than from the ngx-monaco-editor on-load callback.

(<any>window).monaco.editor.getModelMarkers({});

1reaction
imzubair10commented, Jun 11, 2018

Hey @JoshYaxley, good to know that you were able to figure out the fix at your end, just an fyi, my issue is that we’re using older version of Monaco Editor 0.8.2 and this getModelMarkers api is not available in that version

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting errors from Monaco editor - Stack Overflow
It looks like you can call monaco.editor.getModelMarkers({}) to get the list of all markers in the document, and then filter that yourself ...
Read more >
editor | Monaco Editor API
Create a new diff editor under domElement . domElement should be empty (not contain other dom nodes). The editor will read the size...
Read more >
monaco-editor | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >
monaco-editor - UNPKG
Therefore `Uri#fsPath` exists - it's sugar to ease working ... 901, export function getModelMarkers(filter: { ... 919, * Get all the created models....
Read more >
Warnings are not displayed in the error list
Also sometimes numbers(amounts of errors, warnings and messages) are not correct or updated with a long delay. Visual Studiowindows 10.0editorvisual studio 2019 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found