setSelectedRangeWithAffinity(range, affinity) {
    const newRange = super.setSelectedRangeWithAffinity(range, affinity);
    const caret = {
      start: newRange.start,
      end: newRange.start + newRange.length
    };
    this._manualCaret = caret;
    setCaret(this.element, caret.start, caret.end);
    this.selectionAffinity = range.length === 0 ? null : affinity;
  }
Sets the range of the current selection and the selection affinity.

@augments external:InputSim.Input#setSelectedRangeWithAffinity
@param {{start: number, length: number}} range
@param {Affinity} affinity