Skip to content

Commit 5793df5

Browse files
committed
Adding test lineWidgetIssue5486 for #5486
1 parent 672523f commit 5793df5

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

test/test.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1658,6 +1658,56 @@ testCM("lineWidgetChanged", function(cm) {
16581658
eq(info0.top + expectedWidgetHeight, info2.top);
16591659
});
16601660

1661+
testCM("lineWidgetIssue5486", function(cm) {
1662+
// [prepare]
1663+
// 2nd line is combined to 1st line due to markText
1664+
// 2nd line has a lineWidget below
1665+
1666+
cm.setValue("Lorem\nIpsue\nDollar")
1667+
1668+
var el = document.createElement('div')
1669+
el.style.height='50px'
1670+
el.textContent = '[[LINE WIDGET]]'
1671+
1672+
var lineWidget = cm.addLineWidget(1, el, {
1673+
above: false,
1674+
coverGutter: false,
1675+
noHScroll: false,
1676+
showIfHidden: false,
1677+
})
1678+
1679+
var marker = document.createElement('span')
1680+
marker.textContent = '[--]'
1681+
1682+
cm.markText({line:0, ch: 1}, {line:1, ch: 4}, {
1683+
replacedWith: marker
1684+
})
1685+
1686+
// before resizing the lineWidget, measure 3rd line position
1687+
1688+
var measure_1 = Math.round(cm.charCoords({line:2, ch:0}).top)
1689+
1690+
// resize lineWidget, height + 50 px
1691+
1692+
el.style.height='100px'
1693+
el.textContent += "\nlineWidget size changed.\nTry moving cursor to line 3?"
1694+
1695+
lineWidget.changed()
1696+
1697+
// re-measure 3rd line position
1698+
var measure_2 = Math.round(cm.charCoords({line:2, ch:0}).top)
1699+
eq(measure_2, measure_1 + 50)
1700+
1701+
// (extra test)
1702+
//
1703+
// add char to the right of the folded marker
1704+
// and re-measure 3rd line position
1705+
1706+
cm.replaceRange('-', {line:1, ch: 5})
1707+
var measure_3 = Math.round(cm.charCoords({line:2, ch:0}).top)
1708+
eq(measure_3, measure_2)
1709+
});
1710+
16611711
testCM("getLineNumber", function(cm) {
16621712
addDoc(cm, 2, 20);
16631713
var h1 = cm.getLineHandle(1);

0 commit comments

Comments
 (0)