'The reactive range of hovering of Markers is larger than the underlining range
In Monaco Editor, Markers allow to underline a text and display a message when hovering over it. But I just realized that the reactive range of hovering is a little bit larger than the underlining range. As a consequence, messages can be confusing when two markers are adjacent.
For instance, I have the following code which can work in the playground.
If I hover on c (or put the focus between b and c, then press Ctrl+K Ctrl+I), both of the two messages are shown. However, at this location, only the message for c is relevant and expected.
Similarly, if I hover on d (or put the focus between d and e, then press Ctrl+K Ctrl+I), both of the two messages are shown. However, at this location, only the message for d is relevant and expected.
Does anyone know whether it's possible to tweak this behavior of markers (i.e., make the reactive range of hovering exactly same as the underlining range)?
monaco.languages.register({ id: 'myLanguage' });
monaco.editor.onDidCreateModel(function(model) {
var markers = [{
severity: monaco.MarkerSeverity.Error,
startLineNumber: 1,
startColumn: 3,
endLineNumber: 1,
endColumn: 4,
message: 'need to correct c'
},
{
severity: monaco.MarkerSeverity.Error,
startLineNumber: 1,
startColumn: 4,
endLineNumber: 1,
endColumn: 5,
message: 'need to correct d'
}];
monaco.editor.setModelMarkers(model, 'myLanguage', markers);
});
var ed = monaco.editor.create(document.getElementById("container"), {
value: "abcdefg",
language: "myLanguage",
lightbulb: { enabled: false },
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
