Skip to content

Commit

Permalink
Add failing tests for coordsChar
Browse files Browse the repository at this point in the history
1. End of wrapped line in bidi content is wrong (my mistake)
2. coordsChar({left:0, top: *}) in bidi content is wrong after Marijn's code
   style changes
  • Loading branch information
adrianheine authored and marijnh committed Feb 5, 2017
1 parent bb2cf35 commit e49d5e8
Showing 1 changed file with 33 additions and 5 deletions.
38 changes: 33 additions & 5 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1124,13 +1124,41 @@ testCM("measureWrappedEndOfLine", function(cm) {
else break;
}
}
var endPos = cm.charCoords(Pos(0, 12)); // Next-to-last since last would wrap (#1862)
endPos.left += w; // Add width of editor just to be sure that we are behind last character
eqCursorPos(cm.coordsChar(endPos), Pos(0, 13, "before"));
endPos.left += w * 100;
eqCursorPos(cm.coordsChar(endPos), Pos(0, 13, "before"));
for (var i = 0; i < 2; ++i) {
var endPos = cm.charCoords(Pos(0, 12)); // Next-to-last since last would wrap (#1862)
endPos.left += w; // Add width of editor just to be sure that we are behind last character
eqCursorPos(cm.coordsChar(endPos), Pos(0, 13, "before"));
endPos.left += w * 100;
eqCursorPos(cm.coordsChar(endPos), Pos(0, 13, "before"));
cm.setValue("0123456789abcابجابجابجابج");
}
}, {mode: "text/html", value: "0123456789abcde0123456789", lineWrapping: true}, ie_lt8 || opera_lt10);

testCM("measureWrappedBeginOfLine", function(cm) {
if (phantom) return;
cm.setSize(null, "auto");
var inner = byClassName(cm.getWrapperElement(), "CodeMirror-lines")[0].firstChild;
var lh = inner.offsetHeight;
for (var step = 10, w = cm.charCoords(Pos(0, 7), "div").right;; w += step) {
cm.setSize(w);
if (inner.offsetHeight < 2.5 * lh) {
if (step == 10) { w -= 10; step = 1; }
else break;
}
}
var beginOfSecondLine = Pos(0, 13, "after");
for (var i = 0; i < 2; ++i) {
var beginPos = cm.charCoords(Pos(0, 0));
beginPos.left -= w;
eqCursorPos(cm.coordsChar(beginPos), Pos(0, 0, "after"));
beginPos = cm.cursorCoords(beginOfSecondLine);
beginPos.left = 0;
eqCursorPos(cm.coordsChar(beginPos), beginOfSecondLine);
cm.setValue("0123456789abcابجابجابجابج");
beginOfSecondLine = Pos(0, 25, "before");
}
}, {mode: "text/html", value: "0123456789abcde0123456789", lineWrapping: true});

testCM("scrollVerticallyAndHorizontally", function(cm) {
if (cm.getOption("inputStyle") != "textarea") return;
cm.setSize(100, 100);
Expand Down

0 comments on commit e49d5e8

Please sign in to comment.