Skip to content

Commit 4c7472b

Browse files
authored
[SuperEditor] Fix ActionTagComposingReaction looking for composing tag at selection base twice instead of at base and at extent. (#2201)
1 parent 1343eef commit 4c7472b

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

super_editor/lib/src/default_editor/text_tokenizing/action_tags.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ class ActionTagComposingReaction extends EditReaction {
316316
tagRule: _tagRule,
317317
nodeId: textNode.id,
318318
text: textNode.text,
319-
expansionPosition: base.nodePosition as TextNodePosition,
319+
expansionPosition: extent.nodePosition as TextNodePosition,
320320
isTokenCandidate: (attributions) => !attributions.contains(actionTagCancelledAttribution),
321321
);
322322
}

super_editor/test/super_editor/text_entry/tagging/action_tags_test.dart

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,38 @@ void main() {
633633
});
634634
});
635635
});
636+
637+
group("selections >", () {
638+
testWidgetsOnAllPlatforms("can find tag that surrounds the extent position when the selection is expanded",
639+
(tester) async {
640+
await _pumpTestEditor(
641+
tester,
642+
paragraphThenHrDoc(),
643+
);
644+
645+
// Create cancelled action tag
646+
await tester.placeCaretInParagraph("1", 0);
647+
await tester.typeImeText("/header ");
648+
649+
// Place cursor at the end of the horizontal rule/block node
650+
await tester.pressDownArrow();
651+
await tester.pressRightArrow();
652+
653+
// Select upstream towards the cancelled action tag
654+
await expectLater(
655+
() async {
656+
await tester.pressShiftLeftArrow();
657+
await tester.pressShiftUpArrow();
658+
},
659+
returnsNormally,
660+
);
661+
662+
// If we reach the end without exception, then ActionTagComposingReaction did not blow up due to the base or extent
663+
// position, and type of content at those positions.
664+
//
665+
// Original bug: https://github.com/superlistapp/super_editor/pull/2201
666+
});
667+
});
636668
}
637669

638670
Future<TestDocumentContext> _pumpTestEditor(

0 commit comments

Comments
 (0)