selectLine function

bool selectLine(
  1. StateCommandTarget target
)

Expand selection to cover entire lines.

Implementation

bool selectLine(StateCommandTarget target) {
  final state = target.state;
  final blocks = _selectedLineBlocks(state);
  final ranges = blocks.map((block) {
    return EditorSelection.range(
      block.from,
      math.min(block.to + 1, state.doc.length),
    );
  }).toList();

  target.dispatch(state.update([
    TransactionSpec(
      selection: EditorSelection.create(ranges),
      userEvent: 'select',
    ),
  ]));
  return true;
}