Skip to content

Commit

Permalink
Check if offset is valid before using it. The offset might be invalid…
Browse files Browse the repository at this point in the history
… when a user clicks on a location which is after the last character of a line
  • Loading branch information
FlorianKroiss authored and fabioz committed Feb 7, 2024
1 parent f388151 commit a1b4ed4
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,10 @@ public String updatePresentation(Drawable drawable, String hoverInfo, TextPresen

@Override
public void mouseDown(MouseEvent e) {
int offset;
try {
offset = styledText.getOffsetAtPoint(new Point(e.x, e.y));
} catch (IllegalArgumentException e1) {
return; //invalid location
int offset = styledText.getOffsetAtPoint(new Point(e.x, e.y));
if (offset == -1) {
// invalid location
return;
}
StyleRange r = styledText.getStyleRangeAtOffset(offset);
if (r instanceof PyStyleRange) {
Expand Down

0 comments on commit a1b4ed4

Please sign in to comment.