diff --git a/plugins/org.python.pydev.shared_core/src/org/python/pydev/shared_core/string/TextSelectionUtils.java b/plugins/org.python.pydev.shared_core/src/org/python/pydev/shared_core/string/TextSelectionUtils.java index c111a46a21..99ccf8cb28 100644 --- a/plugins/org.python.pydev.shared_core/src/org/python/pydev/shared_core/string/TextSelectionUtils.java +++ b/plugins/org.python.pydev.shared_core/src/org/python/pydev/shared_core/string/TextSelectionUtils.java @@ -760,7 +760,11 @@ public static int getFirstCharRelativePosition(IDocument doc, int cursorOffset) */ public static int getFirstCharPosition(IDocument doc, int cursorOffset) throws BadLocationException { IRegion region; - region = doc.getLineInformationOfOffset(cursorOffset); + try { + region = doc.getLineInformationOfOffset(cursorOffset); + } catch (BadLocationException e) { + throw new BadLocationException("Error: bad offset: " + cursorOffset + " doc len: " + doc.getLength()); + } int offset = region.getOffset(); return offset + getFirstCharRelativePosition(doc, cursorOffset); } @@ -1219,7 +1223,7 @@ public String getContentsFromLineRange(int startLine, int endLine) { */ public static boolean stillInTok(String string, int j) { char c = string.charAt(j); - + return c != '\n' && c != '\r' && c != ' ' && c != '.' && c != '(' && c != ')' && c != ',' && c != ']' && c != '[' && c != '#' && c != '\'' && c != '"'; }