VisualPosition () { ThreadingAssertions.assertEventDispatchThread(); VisualPosition position; SelectionMarker marker = mySelectionMarker; if (hasSelection()) { position = getRangeMarkerStartPosition(); if (position == null) { VisualPosition startPosition = myEditor.offsetToVisualPosition(marker.getStartOffset(), true, false); VisualPosition endPosition = myEditor.offsetToVisualPosition(marker.getEndOffset(), false, true); position = startPosition.after(endPosition) ? endPosition : startPosition; } } else { position = isVirtualSelectionEnabled() ? getVisualPosition() : myEditor.offsetToVisualPosition(getOffset(), getLogicalPosition().leansForward, false); } if (hasVirtualSelection()) { position = new VisualPosition(position.line, position.column + marker.startVirtualOffset); } return position; }