Skip to content

Commit 9e31c01

Browse files
geowarinmarijnh
authored andcommitted
[lint addon] Show all hints in tooltip for overlapping annotations
When hovering a line with multiple lint annotations, codeMirror will now show all the attached markers instead of just the first one
1 parent 3e1e203 commit 9e31c01

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

addon/lint/lint.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,20 +186,27 @@
186186
state.timeout = setTimeout(function(){startLinting(cm);}, state.options.delay || 500);
187187
}
188188

189-
function popupSpanTooltip(ann, e) {
189+
function popupTooltips(annotations, e) {
190190
var target = e.target || e.srcElement;
191-
showTooltipFor(e, annotationTooltip(ann), target);
191+
var tooltip = document.createDocumentFragment();
192+
for (var i = 0; i < annotations.length; i++) {
193+
var ann = annotations[i];
194+
tooltip.appendChild(annotationTooltip(ann));
195+
}
196+
showTooltipFor(e, tooltip, target);
192197
}
193198

194199
function onMouseOver(cm, e) {
195200
var target = e.target || e.srcElement;
196201
if (!/\bCodeMirror-lint-mark-/.test(target.className)) return;
197202
var box = target.getBoundingClientRect(), x = (box.left + box.right) / 2, y = (box.top + box.bottom) / 2;
198203
var spans = cm.findMarksAt(cm.coordsChar({left: x, top: y}, "client"));
204+
205+
var annotations = [];
199206
for (var i = 0; i < spans.length; ++i) {
200-
var ann = spans[i].__annotation;
201-
if (ann) return popupSpanTooltip(ann, e);
207+
annotations.push(spans[i].__annotation);
202208
}
209+
if (annotations.length) popupTooltips(annotations, e);
203210
}
204211

205212
CodeMirror.defineOption("lint", false, function(cm, val, old) {

0 commit comments

Comments
 (0)