Skip to content

Commit ef34d80

Browse files
committed
Reverted reformatting
1 parent 8bc6f6c commit ef34d80

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

super_editor/lib/src/default_editor/common_editor_operations.dart

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2511,7 +2511,7 @@ class PasteEditorCommand extends EditCommand {
25112511
}
25122512

25132513
late DocumentPosition documentPositionAfterPaste;
2514-
if (parsedContent.length > 1) {
2514+
if (parsedContent.length > 1 || parsedContent.first is! TextNode ) {
25152515
// Place the caret at the end of the pasted content.
25162516
final pastedNode = document.getNodeById(previousNode.id)!;
25172517
// ^ re-query the node where we pasted content because nodes are immutable.
@@ -2520,14 +2520,12 @@ class PasteEditorCommand extends EditCommand {
25202520
nodePosition: pastedNode.endPosition,
25212521
);
25222522
} else {
2523-
// The user only pasted content without any newlines in it. Place the
2524-
// caret in the existing node at the end of the pasted text. This is
2525-
// guaranteed to be a TextNode.
2523+
// The user only pasted text content without any newlines in it. Place the
2524+
// caret in the existing text node at the end of the pasted text.
25262525
documentPositionAfterPaste = DocumentPosition(
25272526
nodeId: _pastePosition.nodeId,
25282527
nodePosition: TextNodePosition(
2529-
offset:
2530-
pasteTextOffset + (_parsedContent!.first as TextNode).text.length,
2528+
offset: pasteTextOffset + (_parsedContent!.first as TextNode).text.length,
25312529
),
25322530
);
25332531
}

super_editor/test/super_editor/supereditor_copy_and_paste_test.dart

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import 'package:super_editor/super_editor.dart';
77
import 'package:super_editor/super_editor_test.dart';
88

99
import '../test_runners.dart';
10+
import '../test_tools.dart';
1011
import 'supereditor_test_tools.dart';
1112

1213
void main() {
@@ -50,15 +51,15 @@ void main() {
5051

5152
// Place the caret at the empty paragraph.
5253
await tester.placeCaretInParagraph('1', 0);
53-
54+
5455
// Type some text.
5556
switch (inputSource) {
5657
case TextInputSource.keyboard:
5758
await tester.typeKeyboardText('This is a paragraph');
5859
case TextInputSource.ime:
5960
await tester.typeImeText('This is a paragraph');
6061
}
61-
62+
6263
// Place the cursor somewhere in the middle of the text.
6364
await tester.placeCaretInParagraph('1', 8);
6465

@@ -79,9 +80,9 @@ void main() {
7980
expect((doc.getNodeAt(0)! as ParagraphNode).text.toPlainText(),
8081
'This is some content in a paragraph');
8182
final selection = testContext.composer.selection;
82-
expect(selection, isNotNull);
83-
expect(selection!.isCollapsed, isTrue);
84-
expect((selection.base.nodePosition as TextNodePosition).offset, 24);
83+
expect(selection, selectionEquivalentTo(
84+
const DocumentSelection.collapsed(
85+
position: DocumentPosition(nodeId: '1', nodePosition: TextNodePosition(offset: 24)))));
8586
});
8687

8788

0 commit comments

Comments
 (0)