syncEditorStateFromLineSnapshot function
void
syncEditorStateFromLineSnapshot(
- EditorState editorState,
- TextLineStateSnapshot snapshot, {
- required int lineCount,
- required int lineLength(
- int line
Implementation
void syncEditorStateFromLineSnapshot(
EditorState editorState,
TextLineStateSnapshot snapshot, {
required int lineCount,
required int Function(int line) lineLength,
}) {
final clamped = snapshot.clamp(lineCount: lineCount, lineLength: lineLength);
editorState.setCursor(
line: clamped.cursor.line,
column: clamped.cursor.column,
);
if (clamped.selectionBase == null || clamped.selectionExtent == null) {
editorState.clearSelection();
return;
}
editorState.setSelection(
base: clamped.selectionBase!,
extent: clamped.selectionExtent!,
cursor: clamped.cursor,
);
}