mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Defensive bounds checking
This commit is contained in:
+3
-2
@@ -700,12 +700,13 @@ public class EditorMarkupModelImpl extends MarkupModelImpl implements EditorMark
|
||||
if (myEditorScrollbarTop == -1 || myEditorTargetHeight == -1) {
|
||||
recalcEditorDimensions();
|
||||
}
|
||||
final int safeY = Math.max(0, y - myEditorScrollbarTop);
|
||||
VisualPosition visual;
|
||||
if (myEditorSourceHeight < myEditorTargetHeight) {
|
||||
visual = myEditor.xyToVisualPosition(new Point(0, y - myEditorScrollbarTop));
|
||||
visual = myEditor.xyToVisualPosition(new Point(0, safeY));
|
||||
}
|
||||
else {
|
||||
float fraction = Math.max(0, Math.min(1, (y - myEditorScrollbarTop) / (float)myEditorTargetHeight));
|
||||
float fraction = Math.max(0, Math.min(1, safeY / (float)myEditorTargetHeight));
|
||||
final int lineCount = myEditorSourceHeight / myEditor.getLineHeight();
|
||||
visual = new VisualPosition((int)(fraction * lineCount),0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user