lineSnapshotFromOffsets function
TextLineStateSnapshot
lineSnapshotFromOffsets(
- TextDocument document, {
- required int cursorOffset,
- int? selectionBaseOffset,
- int? selectionExtentOffset,
Implementation
TextLineStateSnapshot lineSnapshotFromOffsets(
TextDocument document, {
required int cursorOffset,
int? selectionBaseOffset,
int? selectionExtentOffset,
}) {
final cursor = document.positionForOffset(
cursorOffset.clamp(0, document.length),
);
if (selectionBaseOffset == null || selectionExtentOffset == null) {
return TextLineStateSnapshot.collapsed(cursor: cursor);
}
return TextLineStateSnapshot.selection(
base: document.positionForOffset(
selectionBaseOffset.clamp(0, document.length),
),
extent: document.positionForOffset(
selectionExtentOffset.clamp(0, document.length),
),
cursor: cursor,
);
}