Fix a bug that empty delta would be treated as retain and cause cursor to not move

pull/17/head
singerdmx 4 years ago
parent b7409992c0
commit 8fe232f4d5
  1. 5
      CHANGELOG.md
  2. 2
      app/pubspec.lock
  3. 4
      lib/utils/diff_delta.dart
  4. 2
      lib/widgets/controller.dart
  5. 2
      pubspec.yaml

@ -66,4 +66,7 @@
* Support custom styles and image on local device storage without uploading. * Support custom styles and image on local device storage without uploading.
## [0.2.4] ## [0.2.4]
* Support the use of custom icon size in toolbar. * Support the use of custom icon size in toolbar.
## [0.2.5]
* Toggle text/background color button in toolbar.

@ -82,7 +82,7 @@ packages:
path: ".." path: ".."
relative: true relative: true
source: path source: path
version: "0.2.4" version: "0.2.5"
flutter_test: flutter_test:
dependency: "direct dev" dependency: "direct dev"
description: flutter description: flutter

@ -67,6 +67,10 @@ Diff getDiff(String oldText, String newText, int cursorPosition) {
} }
int getPositionDelta(Delta user, Delta actual) { int getPositionDelta(Delta user, Delta actual) {
if (actual.isEmpty) {
return 0;
}
DeltaIterator userItr = DeltaIterator(user); DeltaIterator userItr = DeltaIterator(user);
DeltaIterator actualItr = DeltaIterator(actual); DeltaIterator actualItr = DeltaIterator(actual);
int diff = 0; int diff = 0;

@ -100,7 +100,7 @@ class QuillController extends ChangeNotifier {
toggledStyle = Style(); toggledStyle = Style();
if (textSelection != null) { if (textSelection != null) {
if (delta == null) { if (delta == null || delta.isEmpty) {
_updateSelection(textSelection, ChangeSource.LOCAL); _updateSelection(textSelection, ChangeSource.LOCAL);
} else { } else {
try { try {

@ -1,6 +1,6 @@
name: flutter_quill name: flutter_quill
description: One client and affiliated collaborator of Flutter Quill is Bullet Journal App. description: One client and affiliated collaborator of Flutter Quill is Bullet Journal App.
version: 0.2.4 version: 0.2.5
#author: bulletjournal #author: bulletjournal
homepage: https://bulletjournal.us/home/index.html homepage: https://bulletjournal.us/home/index.html
repository: https://github.com/singerdmx/flutter-quill.git repository: https://github.com/singerdmx/flutter-quill.git

Loading…
Cancel
Save