1
1
import 'dart:async' ;
2
2
import 'dart:convert' ;
3
3
import 'dart:math' as math;
4
+
4
5
// ignore: unnecessary_import
5
6
import 'dart:typed_data' ;
6
7
@@ -266,6 +267,7 @@ class RawEditorState extends EditorState
266
267
267
268
// Focus
268
269
bool _didAutoFocus = false ;
270
+
269
271
bool get _hasFocus => widget.focusNode.hasFocus;
270
272
271
273
// Theme
@@ -275,6 +277,7 @@ class RawEditorState extends EditorState
275
277
@override
276
278
List <Tuple2 <int , Style >> get pasteStyle => _pasteStyle;
277
279
List <Tuple2 <int , Style >> _pasteStyle = < Tuple2 <int , Style >> [];
280
+
278
281
@override
279
282
String get pastePlainText => _pastePlainText;
280
283
String _pastePlainText = '' ;
@@ -554,13 +557,13 @@ class RawEditorState extends EditorState
554
557
}
555
558
556
559
void _updateSelectionForKeyPhrase (String phrase, Attribute attribute) {
560
+ controller.replaceText (controller.selection.baseOffset - phrase.length,
561
+ phrase.length, '\n ' , null );
562
+ _moveCursor (- phrase.length);
557
563
controller
558
564
..formatSelection (attribute)
559
- ..replaceText (controller.selection.baseOffset - phrase.length,
560
- phrase.length, '' , null );
561
-
562
- // It is unclear why the selection moves forward the edit distance.
563
- _moveCursor (- 2 );
565
+ // Remove the added newline.
566
+ ..replaceText (controller.selection.baseOffset + 1 , 1 , '' , null );
564
567
}
565
568
566
569
void _handleSelectionChanged (
@@ -1678,6 +1681,7 @@ class _DocumentBoundary extends _TextBoundary {
1678
1681
@override
1679
1682
TextPosition getLeadingTextBoundaryAt (TextPosition position) =>
1680
1683
const TextPosition (offset: 0 );
1684
+
1681
1685
@override
1682
1686
TextPosition getTrailingTextBoundaryAt (TextPosition position) {
1683
1687
return TextPosition (
0 commit comments