Skip to content

Commit 200e11a

Browse files
Vipas-anabobbylight
authored andcommitted
Prevent divide by 0 exception and cleanup
It seems a check was missed, since we initialize lineHeight to 0... this fixes arduino/Arduino#7861
1 parent 46ded3a commit 200e11a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/main/java/org/fife/ui/rsyntaxtextarea/SyntaxView.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -946,11 +946,12 @@ else if (y > alloc.y + alloc.height) {
946946
else {
947947

948948
Element map = doc.getDefaultRootElement();
949+
lineHeight = host!=null ? host.getLineHeight() : lineHeight;
949950
int lineIndex = Math.abs((y - alloc.y) / lineHeight);//metrics.getHeight() );
950-
FoldManager fm = host.getFoldManager();
951-
//System.out.print("--- " + lineIndex);
952-
lineIndex += fm.getHiddenLineCountAbove(lineIndex, true);
953-
//System.out.println(" => " + lineIndex);
951+
FoldManager fm = host.getFoldManager();
952+
//System.out.print("--- " + lineIndex);
953+
lineIndex += fm.getHiddenLineCountAbove(lineIndex, true);
954+
//System.out.println(" => " + lineIndex);
954955
if (lineIndex >= map.getElementCount()) {
955956
return host.getLastVisibleOffset();
956957
}
@@ -1019,4 +1020,4 @@ public int yForLineContaining(Rectangle alloc, int offs)
10191020
}
10201021

10211022

1022-
}
1023+
}

0 commit comments

Comments
 (0)