An attemp to fix the text selection bug

pull/1643/head
Ellet 1 year ago
parent 7686afdc99
commit 4713a14bed
  1. 2
      lib/src/models/documents/document.dart
  2. 0
      lib/src/widgets/quill/C
  3. 9
      lib/src/widgets/quill/quill_controller.dart

@ -218,7 +218,7 @@ class Document {
if (res.node is Line) { if (res.node is Line) {
return res; return res;
} }
final block = res.node as Block; final block = res.node as Block; // TODO: Can be nullable, handle this case
return block.queryChild(res.offset, true); return block.queryChild(res.offset, true);
} }

@ -251,8 +251,13 @@ class QuillController extends ChangeNotifier {
// updateSelection( // updateSelection(
// TextSelection.collapsed(offset: document.length), ChangeSource.LOCAL); // TextSelection.collapsed(offset: document.length), ChangeSource.LOCAL);
updateSelection( updateSelection(
TextSelection.collapsed(offset: selection.baseOffset + len), (selection.baseOffset + len) > 0
ChangeSource.local); ? TextSelection.collapsed(
offset: selection.baseOffset + len,
)
: TextSelection.collapsed(offset: document.length),
ChangeSource.local,
);
} else { } else {
// no need to move cursor // no need to move cursor
notifyListeners(); notifyListeners();

Loading…
Cancel
Save