VisualPosition (int startOffset, int endOffset) { int firstLine = myDocument.getLineNumber(startOffset); int lastLine = myDocument.getLineNumber(endOffset); VisualPosition positionWithMaxColumn = new VisualPosition(0, 0); for (int currentLine = firstLine; currentLine <= lastLine; currentLine++) { int offset = myDocument.getLineEndOffset(currentLine); VisualPosition position = myEditor.offsetToVisualPosition(offset); if (position.getColumn() > positionWithMaxColumn.getColumn()) { positionWithMaxColumn = position; } } return positionWithMaxColumn; }