Skip to content

Commit

Permalink
[annotatescrollbar addon] Simplify visual-line finding
Browse files Browse the repository at this point in the history
Issue #6388
  • Loading branch information
marijnh committed Aug 19, 2020
1 parent 55d0484 commit ac4aaa0
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions addon/scroll/annotatescrollbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,15 @@
var singleLineH = wrapping && cm.defaultTextHeight() * 1.5;
var curLine = null, curLineObj = null;

function getFoldLineHandle(pos) {
var marks = cm.findMarksAt(pos);
for (var i = 0; i < marks.length; ++i) {
if (marks[i].collapsed)
return marks[i].lines[0];
}
}

function getY(pos, top) {
if (curLine != pos.line) {
curLine = pos.line;
if(!(curLineObj = getFoldLineHandle(pos)))
curLineObj = cm.getLineHandle(curLine);
curLine = pos.line
curLineObj = cm.getLineHandle(pos.line)
var visual = cm.getLineHandleVisualStart(curLineObj)
if (visual != curLineObj) {
curLine = cm.getLineNumber(visual)
curLineObj = visual
}
}
if ((curLineObj.widgets && curLineObj.widgets.length) ||
(wrapping && curLineObj.height > singleLineH))
Expand Down

0 comments on commit ac4aaa0

Please sign in to comment.