Skip to content

Commit 4def0b2

Browse files
Adam Ahmedmarijnh
authored andcommitted
Set parent width for coverGutter widgets in measure div
When using the measure div to measure a LineWidget with coverGutter: true, set the parent's width to include the gutter. Otherwise, the widget will be measured as if it were not meant to cover the gutter (it will be measured at a narrower width). Fixes #2611
1 parent 2477a1f commit 4def0b2

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/codemirror.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5541,8 +5541,12 @@
55415541

55425542
function widgetHeight(widget) {
55435543
if (widget.height != null) return widget.height;
5544-
if (!contains(document.body, widget.node))
5545-
removeChildrenAndAdd(widget.cm.display.measure, elt("div", [widget.node], null, "position: relative"));
5544+
if (!contains(document.body, widget.node)) {
5545+
var parentStyle = "position: relative;";
5546+
if (widget.coverGutter)
5547+
parentStyle += "margin-left: -" + widget.cm.getGutterElement().offsetWidth + "px;";
5548+
removeChildrenAndAdd(widget.cm.display.measure, elt("div", [widget.node], null, parentStyle));
5549+
}
55465550
return widget.height = widget.node.offsetHeight;
55475551
}
55485552

0 commit comments

Comments
 (0)