@@ -1080,12 +1080,10 @@ void calculateTopIndex(int delta) {
10801080 int lineCount = content .getLineCount ();
10811081 if (delta >= 0 ) {
10821082 delta -= topIndexY ;
1083- int lineIndex = topIndex ;
1083+ int lineIndex = Math . max ( 0 , topIndex ) ;
10841084 while (lineIndex < lineCount ) {
10851085 if (delta <= 0 ) break ;
1086- if (lineIndex >= 0 && lineIndex < lineCount ) {
1087- delta -= renderer .getCachedLineHeight (lineIndex );
1088- }
1086+ delta -= renderer .getCachedLineHeight (lineIndex );
10891087 lineIndex ++;
10901088 }
10911089 int lineHeight = 0 ;
@@ -1097,11 +1095,10 @@ void calculateTopIndex(int delta) {
10971095 topIndexY = -delta ;
10981096 } else {
10991097 topIndex = lineIndex - 1 ;
1100- int topIndexHeight = 0 ;
11011098 if (topIndex >= 0 && topIndex < lineCount ) {
1102- topIndexHeight = renderer .getCachedLineHeight (topIndex );
1099+ topIndexY = - renderer .getCachedLineHeight (topIndex );
11031100 }
1104- topIndexY = - topIndexHeight - delta ;
1101+ topIndexY -= delta ;
11051102 }
11061103 } else {
11071104 delta -= topIndexY ;
@@ -3902,10 +3899,7 @@ public int getLinePixel(int lineIndex) {
39023899 return topIndexY + topMargin ;
39033900 int height = topIndexY ;
39043901 if (lineIndex > topIndex ) {
3905- for (int i = topIndex ; i < lineIndex ; i ++) {
3906- if (i < 0 || i >= lineCount ) {
3907- continue ;
3908- }
3902+ for (int i = Math .max (topIndex , 0 ); i < Math .min (lineIndex , lineCount ); i ++) {
39093903 height += renderer .getLineHeight (i );
39103904 }
39113905 } else {
0 commit comments