lineSnapshotFromEditorState function
TextLineStateSnapshot
lineSnapshotFromEditorState(
- EditorState editorState, {
- required int lineCount,
- required int lineLength(
- int line
- bool preserveCollapsedSelection = false,
Implementation
TextLineStateSnapshot lineSnapshotFromEditorState(
EditorState editorState, {
required int lineCount,
required int Function(int line) lineLength,
bool preserveCollapsedSelection = false,
}) {
final cursor = _clampPositionToLines(
editorState.cursor,
lineCount: lineCount,
lineLength: lineLength,
);
final selection = editorState.selection;
if (selection == null ||
(selection.isCollapsed && !preserveCollapsedSelection)) {
return TextLineStateSnapshot.collapsed(cursor: cursor);
}
return TextLineStateSnapshot.selection(
base: _clampPositionToLines(
selection.base,
lineCount: lineCount,
lineLength: lineLength,
),
extent: _clampPositionToLines(
selection.extent,
lineCount: lineCount,
lineLength: lineLength,
),
cursor: cursor,
preserveCollapsedSelection: preserveCollapsedSelection,
);
}