int (HighlightInfo info, Document document) { int start = info.getActualStartOffset(); if (start >= document.getTextLength()) return document.getTextLength(); char c = document.getCharsSequence().charAt(start); int shift = info.isAfterEndOfLine() && c != '\n' ? 1 : info.navigationShift; int offset = info.getActualStartOffset() + shift; return Math.min(offset, document.getTextLength()); }