I'm killing myself trying to figure out how to get access to the info/warning/error markers created by the language linters. Is this possible?
I've found how I can access decorations (IModel.onDidChangeDecorations and a few get... methods in ITextModelWithDecorations). I can filter for decorations that are "IModelDecorationsChangedEventDecorationData.isForValidation), but that doesn't give me access to the marker.
I've found how I can SET markers (monaco.editor.setModelMarkers).
Am I missing something, or are the markers currently not exposed? Is there a preferred method of enumerating errors and warnings?
some ideas how to do it: https://github.com/Microsoft/vscode/issues/7232#issuecomment-229692270
specifically for typescript, a total hack but if you relate the editor to its model, theres a line in mode.js thats
monaco.editor.setModelMarkers(monaco.editor.getModel(e), t._selector, r)
and I think r are all the markers for the editor.
Has anything changed here or is it still not possible to access markers or error messages?
Please take a look at https://github.com/Microsoft/vscode/pull/31045. Does it provide required API?
Thanks @electroma. It does appear that this would be sufficient. I had to drop Monaco for Ace a while back because of this (and lack of HTML+CSS linting) for my specific project. However, I'll definitely revisit it once this PR is merged, as I do like the editor better in general.
Thanks for you prompt reply @ptyork! I'm trying to make similar decision now. In my case it's JSON editor with custom validation and autocompletion. Monaco looks very good, but some vscode APIs are not exposed now.
the good thing about open source software -> I get markers like this
var setModelMarkers = monaco.editor.setModelMarkers;
monaco.editor.setModelMarkers = function (model, owner, markers) {
setModelMarkers.call(monaco.editor, model, owner, markers);
if (markers.length == 0) {
//there are no errors
}
else
{
//there are errors
}
}
Thank you for workaround @wysisoft! Sure it's possible to monkey patch monaco, but only in a short term.
Most helpful comment
the good thing about open source software -> I get markers like this
var setModelMarkers = monaco.editor.setModelMarkers;
monaco.editor.setModelMarkers = function (model, owner, markers) {
setModelMarkers.call(monaco.editor, model, owner, markers);
if (markers.length == 0) {
//there are no errors
}
else
{
//there are errors
}
}