textJoinLinesDocument function

TextCommandResult textJoinLinesDocument({
  1. required TextDocument document,
  2. required TextLineStateSnapshot state,
})

Implementation

TextCommandResult textJoinLinesDocument({
  required TextDocument document,
  required TextLineStateSnapshot state,
}) {
  final clampedState = _clampLineStateSnapshotToDocument(state, document);
  final selectedSpan = _selectedLineSpan(clampedState);
  final endLine = clampedState.hasSelection
      ? selectedSpan.endLine
      : (selectedSpan.startLine + 1).clamp(0, document.lineCount - 1);
  return _documentResultFromWindowedLineCommand(
    document: document,
    state: clampedState,
    startLine: selectedSpan.startLine,
    endLine: endLine + 1,
    apply: (lines, localState) =>
        textJoinLines(lines: lines, state: localState),
  );
}