Coordinates () { Coordinates c = super.getCoordinates(); if (c != null) return c; Matcher relativeMatcher = relativeNumberPattern.matcher(getText()); if (relativeMatcher.matches()) { int caretLine = myEditor.getCaretModel().getLogicalPosition().line; int relativeLine = Integer.parseInt(relativeMatcher.group(1)); int logicalLine = RelativeLineHelper.INSTANCE.getLogicalLine(myEditor, caretLine, relativeLine); int linesTotal = myEditor.getDocument().getLineCount(); return new Coordinates(Math.max(0, Math.min(logicalLine, linesTotal - 1)), 0); } return null; }