Skip to content

Commit

Permalink
[SuperEditor] Fix ActionTagComposingReaction looking for composing ta…
Browse files Browse the repository at this point in the history
…g at selection base twice instead of at base and at extent. (#2201)
  • Loading branch information
KevinBrendel authored Aug 10, 2024
1 parent 1343eef commit 4c7472b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ class ActionTagComposingReaction extends EditReaction {
tagRule: _tagRule,
nodeId: textNode.id,
text: textNode.text,
expansionPosition: base.nodePosition as TextNodePosition,
expansionPosition: extent.nodePosition as TextNodePosition,
isTokenCandidate: (attributions) => !attributions.contains(actionTagCancelledAttribution),
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,38 @@ void main() {
});
});
});

group("selections >", () {
testWidgetsOnAllPlatforms("can find tag that surrounds the extent position when the selection is expanded",
(tester) async {
await _pumpTestEditor(
tester,
paragraphThenHrDoc(),
);

// Create cancelled action tag
await tester.placeCaretInParagraph("1", 0);
await tester.typeImeText("/header ");

// Place cursor at the end of the horizontal rule/block node
await tester.pressDownArrow();
await tester.pressRightArrow();

// Select upstream towards the cancelled action tag
await expectLater(
() async {
await tester.pressShiftLeftArrow();
await tester.pressShiftUpArrow();
},
returnsNormally,
);

// If we reach the end without exception, then ActionTagComposingReaction did not blow up due to the base or extent
// position, and type of content at those positions.
//
// Original bug: https://github.com/superlistapp/super_editor/pull/2201
});
});
}

Future<TestDocumentContext> _pumpTestEditor(
Expand Down

0 comments on commit 4c7472b

Please sign in to comment.