@Override
  public @NotNull VisualPosition getLeadSelectionPosition() {
    SelectionMarker marker = mySelectionMarker;
    VisualPosition caretPosition = getVisualPosition();
    if (isVirtualSelectionEnabled() && !hasSelection()) {
      return caretPosition;
    }
    if (marker == null || !marker.isValid()) {
      return caretPosition;
    }

    if (isRangeMarkerEndPositionIsLead()) {
      VisualPosition result = getRangeMarkerEndPosition();
      if (result == null) {
        return getSelectionEndPosition();
      }
      else {
        if (hasVirtualSelection()) {
          result = new VisualPosition(result.line, result.column + marker.endVirtualOffset);
        }
        return result;
      }
    }
    else {
      VisualPosition result = getRangeMarkerStartPosition();
      if (result == null) {
        return getSelectionStartPosition();
      }
      else {
        if (hasVirtualSelection()) {
          result = new VisualPosition(result.line, result.column + marker.startVirtualOffset);
        }
        return result;
      }
    }
  }
@Override
  public @NotNull VisualPosition getLeadSelectionPosition()