unwrapSelection method

bool unwrapSelection()

Removes a matching surrounding delimiter pair around the current selection and preserves the inner selection.

Returns false when there is no active selection, the selection is empty, or the surrounding graphemes do not form a known delimiter pair.

Implementation

bool unwrapSelection() {
  if (!_hasSelection()) return false;
  return _runEditFrame(() {
    _beginHistoryAction(_TextAreaHistoryAction.transform, breakChain: true);
    _refreshDocumentSnapshot();
    final result = textUnwrapSelection(
      document: _document,
      state: _currentOffsetStateSnapshot(),
      surroundPairs: _selectionSurroundPairs,
    );
    if (!result.changed) {
      return false;
    }

    _recordUndoSnapshot();
    _applyOffsetCommandResult(result);
    return true;
  });
}