VisualPosition (final int offset) { int line = myDocument.getLineNumber(offset); final int lineStartOffset = myDocument.getLineStartOffset(line); return new VisualPosition(line, offset - lineStartOffset); }