Keep cursor position on checkbox tap (#834)

pull/839/head
Pavel Kozlovskiy 3 years ago committed by GitHub
parent bad872c347
commit d339997969
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      lib/src/widgets/raw_editor.dart

@ -411,6 +411,8 @@ class RawEditorState extends EditorState
void _handleCheckboxTap(int offset, bool value) {
if (!widget.readOnly) {
_disableScrollControllerAnimateOnce = true;
widget.controller.ignoreFocusOnTextChange = true;
final currentSelection = widget.controller.selection.copyWith();
final attribute = value ? Attribute.checked : Attribute.unchecked;
widget.controller.formatText(offset, 0, attribute);
@ -424,8 +426,8 @@ class RawEditorState extends EditorState
// Go back from offset 0 to current selection
SchedulerBinding.instance.addPostFrameCallback((_) {
widget.controller.updateSelection(
TextSelection.collapsed(offset: offset), ChangeSource.LOCAL);
widget.controller.ignoreFocusOnTextChange = false;
widget.controller.updateSelection(currentSelection, ChangeSource.LOCAL);
});
}
}

Loading…
Cancel
Save