Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access to Markers? #30

Closed
ptyork opened this issue Jun 25, 2016 · 8 comments · Fixed by microsoft/vscode#31045
Closed

Access to Markers? #30

ptyork opened this issue Jun 25, 2016 · 8 comments · Fixed by microsoft/vscode#31045
Labels
editor-core feature-request Request for new features or functionality
Milestone

Comments

@ptyork
Copy link

ptyork commented Jun 25, 2016

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?

@jrieken jrieken added the help wanted Issues identified as good community contribution opportunities label Jun 30, 2016
@jrieken
Copy link
Member

jrieken commented Jun 30, 2016

some ideas how to do it: microsoft/vscode#7232 (comment)

@wysisoft
Copy link

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.

@domoritz
Copy link
Contributor

domoritz commented Jul 3, 2017

Has anything changed here or is it still not possible to access markers or error messages?

@electroma
Copy link

electroma commented Jul 19, 2017

Please take a look at microsoft/vscode#31045. Does it provide required API?

@ptyork
Copy link
Author

ptyork commented Jul 19, 2017

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.

@electroma
Copy link

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.

@wysisoft
Copy link

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
}
}

@electroma
Copy link

Thank you for workaround @wysisoft! Sure it's possible to monkey patch monaco, but only in a short term.

electroma added a commit to electroma/vscode that referenced this issue Jul 21, 2017
As of now there is no public API to access markers. This PR adds method `editor.getModelMarkers`. Should resolve
microsoft/monaco-editor#30.
@vscodebot vscodebot bot locked and limited conversation to collaborators Oct 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
editor-core feature-request Request for new features or functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants
@domoritz @ptyork @jrieken @electroma @alexdima @wysisoft and others