From 8fe232f4d55d45ed8973ee52059ff9e1423b4b4e Mon Sep 17 00:00:00 2001 From: singerdmx Date: Sun, 7 Feb 2021 15:12:04 -0800 Subject: [PATCH] Fix a bug that empty delta would be treated as retain and cause cursor to not move --- CHANGELOG.md | 5 ++++- app/pubspec.lock | 2 +- lib/utils/diff_delta.dart | 4 ++++ lib/widgets/controller.dart | 2 +- pubspec.yaml | 2 +- 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8decc4a3..e8eca226 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -66,4 +66,7 @@ * Support custom styles and image on local device storage without uploading. ## [0.2.4] -* Support the use of custom icon size in toolbar. \ No newline at end of file +* Support the use of custom icon size in toolbar. + +## [0.2.5] +* Toggle text/background color button in toolbar. \ No newline at end of file diff --git a/app/pubspec.lock b/app/pubspec.lock index feb97033..93f1f182 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -82,7 +82,7 @@ packages: path: ".." relative: true source: path - version: "0.2.4" + version: "0.2.5" flutter_test: dependency: "direct dev" description: flutter diff --git a/lib/utils/diff_delta.dart b/lib/utils/diff_delta.dart index 6de3c0af..49a06dab 100644 --- a/lib/utils/diff_delta.dart +++ b/lib/utils/diff_delta.dart @@ -67,6 +67,10 @@ Diff getDiff(String oldText, String newText, int cursorPosition) { } int getPositionDelta(Delta user, Delta actual) { + if (actual.isEmpty) { + return 0; + } + DeltaIterator userItr = DeltaIterator(user); DeltaIterator actualItr = DeltaIterator(actual); int diff = 0; diff --git a/lib/widgets/controller.dart b/lib/widgets/controller.dart index 9ce00ca8..5bd6b2d8 100644 --- a/lib/widgets/controller.dart +++ b/lib/widgets/controller.dart @@ -100,7 +100,7 @@ class QuillController extends ChangeNotifier { toggledStyle = Style(); if (textSelection != null) { - if (delta == null) { + if (delta == null || delta.isEmpty) { _updateSelection(textSelection, ChangeSource.LOCAL); } else { try { diff --git a/pubspec.yaml b/pubspec.yaml index be678d06..a06e89b5 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_quill description: One client and affiliated collaborator of Flutter Quill is Bullet Journal App. -version: 0.2.4 +version: 0.2.5 #author: bulletjournal homepage: https://bulletjournal.us/home/index.html repository: https://github.com/singerdmx/flutter-quill.git