style fetch fix on editing between different blocks (#496)

pull/499/head
Andy Trand 3 years ago committed by GitHub
parent b59e360091
commit d23e161d1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      lib/src/models/documents/nodes/container.dart
  2. 9
      lib/src/widgets/raw_editor/raw_editor_state_text_input_client_mixin.dart

@ -94,7 +94,7 @@ abstract class Container<T extends Node?> extends Node {
for (final node in children) {
final len = node.length;
if (offset < len || (inclusive && offset == len && node.isLast)) {
if (offset < len || (inclusive && offset == len)) {
return ChildQuery(node, offset);
}
offset -= len;

@ -2,6 +2,7 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import '../../models/documents/document.dart';
import '../../utils/diff_delta.dart';
import '../editor.dart';
@ -167,8 +168,12 @@ mixin RawEditorStateTextInputClientMixin on EditorState
final text = value.text;
final cursorPosition = value.selection.extentOffset;
final diff = getDiff(oldText, text, cursorPosition);
widget.controller.replaceText(
diff.start, diff.deleted.length, diff.inserted, value.selection);
if (diff.deleted.isEmpty && diff.inserted.isEmpty) {
widget.controller.updateSelection(value.selection, ChangeSource.LOCAL);
} else {
widget.controller.replaceText(
diff.start, diff.deleted.length, diff.inserted, value.selection);
}
}
@override

Loading…
Cancel
Save