-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
SetModelMarkers shows "Undefined" as error message #790
Comments
This works fine for me: var ed = monaco.editor.create(document.getElementById("container"), {
value: "function hello() {\n\talert('Hello world!');\n}",
language: "javascript"
});
monaco.editor.setModelMarkers(ed.getModel(), 'test', [{
startLineNumber: 2,
startColumn: 1,
endLineNumber: 2,
endColumn: 1000,
message: "a message",
severity: monaco.Severity.Warning
}]) |
I tried the same, still the message says "undefined".
Trying the same with Monaco playground working fine. |
I have same issue to, after upgrading to latest manco version. |
@ryanlin1986 Are you also using Angular 4? |
I have similar "undefined" issue with a bit different steps but I think root cause is the same. This example from monaco playground when running from Angular 5 application produces "undefined" when you hover over warning on enum value, other warnings like "Missing property XXX" are affected too. Issue is happening when signalInnerHTML is executed which triggers Promise.all resolving above it. But the issue is actually on Angular's Zone.js side as it re-defines promises. It has to be fixed in Promise.all definition, index/count mismatch is happening in monaco-editor case. The only workaround I have for now is by redefining Promise.all with a fix locally (e.g. within polyfills.ts)
|
Because of a few bugs in the new version: microsoft/monaco-editor#772 microsoft/monaco-editor#790
@rcjsuen Hi, I'm not using angular at all, just plain javascript |
@ryanlin1986 Can you reproduce the problem in the playground? |
@ryanlin1986 try using Monaco editor version 0.10.1. The "undefined" issue is there from version 0.11.0. |
@rcjsuen turns out it is because of the Promise polyfills, same as angular issue. |
Previous version of monaco-editor doesn't have this issue because there was no signalInnerHTML routine there. Monaco-editor can actually do proactive check to don't have this issue by verifying if strValue is truthy here. |
@taras-mytofir Is this an issue we should file against Angular's Zone.js. I think |
@alexandrudima I wanted to do that but wasn't able to prepare inline example quickly which would illustrate this issue as some specific promises are created inside monaco and I didn't have time to further dig into the monaco-editor's code. Some example like here (this one works fine) would be good. If somebody understands better what exactly is happening inside monaco-editor's case this is angular 5 plunkr app which can be used to prepare such inline example using developer tools console as promises there are Zone.js' ones. I think after we have such example we can create issue on Zone.js side. |
@taras-mytofir Here is the repro https://plnkr.co/edit/UO2QhIa5eeLm6tPAyAjt?p=preview VSCode historically used WinJS Promises... and we are slowly moving to the standard
The output I get from |
@taras-mytofir . Can you suggest a solution to work around this ? . I am using monaco-edtior version 0.13 with angular 5 and face the same issue |
@buinhansinh I mentioned my workaround in this comment. |
@taras-mytofir , is it possible to use Line Decorator instead of Model Markers ? Decorators |
I've spent days trying to figure out why JSON validation messages won't work in Angular. Thanks @taras-mytofir for the #790 (comment). Helps a lot as a short term solution. |
Have to give people kudos debugging this stuff out. I wonder if fixed microsoft/vscode#53526 eventually gives working monaco without these workarounds? |
Error was caused due to discrepancies between zone.js and monaco editor Promise.all implementation. Added polyfill patch for short term solution. Track issues: - microsoft/monaco-editor#790 - angular/zone.js#1077
Error was caused due to discrepancies between zone.js and monaco editor Promise.all implementation. Added polyfill patch for short term solution. Track issues: - microsoft/monaco-editor#790 - angular/zone.js#1077
@jrieken I see that removal of WinJS.Promise is an epic you're working on. Would you be open to a PR fixing this issue specifically? Changing MarkdownRenderer.getOptions' codeBlockRenderer to return a native promise? Or perhaps ModeServiceImpl._onReady to use Promise.resolve(true) instead of WinJS.Promise.as(true) ? |
Sure, go ahead but try to keep it small or contained to one area. |
For ZoneAwarePromise.all, as [implemented](https://github.com/angular/zone.js/blob/7201d44451f6c67eac2b86eca3cbfafde14035d6/lib/common/promise.ts), the `count` variable serves three purposes: 1. Count the number of values passed-in 2. Specify the index of a resolved value in `resolvedValues` 3. Track when all the promises have been resolved. In the event that `value.then` is immediately called, `count` will be decremented at the incorrect time resulting in a potentially negative value or reaching 0 when not all values have actually been resolved. The fix is to be more meticulous about using the correct indices at the correct time and to not overload the count and number of resolved promises. This updated version is more explicit about the purpose of the `unresolvedCount` and `valueIndex` variables. `unresolvedCount` needs to start at 2 to prevent `resolve` from being called too soon in the event that `value.then` calls the callback immediately. The scoping of the index for use in `resolvedValues` is made constant to guarantee the correct index is used. This buggy behavior specifically manifested as an issue in the Monaco editor but most likely occurs elsewhere as well in cases where promises may immediately call into `.then`. Related issue: microsoft/monaco-editor#790 (comment)
We have now migrated to native promises entirely. |
Hi,
I am using "setModelMarkers()" to highlight the syntax errors in Monaco editor for my custom language.
The message added to the marker is not getting displayed on hovering over the highlighted text.
The message always shows as "undefined".
Please let me know if any thing is missed or done wrong.
monaco-editor version: 0.11.1
Browser: Chrome
OS: win 7
The text was updated successfully, but these errors were encountered: