From a1b4ed47c6b8f57e48dcdf415f334e85fe6b4265 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kroi=C3=9F=2C=20Florian?= Date: Wed, 7 Feb 2024 11:46:25 +0100 Subject: [PATCH] Check if offset is valid before using it. The offset might be invalid when a user clicks on a location which is after the last character of a line --- .../org/python/pydev/editor/PyInformationPresenter.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/plugins/org.python.pydev/src/org/python/pydev/editor/PyInformationPresenter.java b/plugins/org.python.pydev/src/org/python/pydev/editor/PyInformationPresenter.java index 0c31aefbec..84dfa8bbf1 100644 --- a/plugins/org.python.pydev/src/org/python/pydev/editor/PyInformationPresenter.java +++ b/plugins/org.python.pydev/src/org/python/pydev/editor/PyInformationPresenter.java @@ -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) {