setSelection method

void setSelection(
  1. Position anchor, {
  2. Position? head,
  3. Map? options,
})

Set a single selection range. anchor and head should be {line, ch} objects. head defaults to anchor when not given. These options are supported:

scroll: determines whether the selection head should be scrolled into view. Defaults to true.

origin: determines whether the selection history event may be merged with the previous one. When an origin starts with the character +, and the last recorded selection had the same origin and was similar (close in time, both collapsed or both non-collapsed), the new one will replace the old one. When it starts with///, it will always replace the previous event (if that had the same origin). Built-in motion uses the "+move" origin.

bias: determine the direction into which the selection endpoints should be adjusted when they fall inside an atomic range. Can be either -1 (backward) or 1 (forward). When not given, the bias will be based on the relative position of the old selection—the editor will try to move further away from that, to prevent getting stuck.

Implementation

void setSelection(Position anchor, {Position? head, Map? options}) {
  callArgs('setSelection', [anchor.toProxy(), head?.toProxy(), options]);
}