Skip to content

Commit

Permalink
[SuperEditor]- Make getDocumentPositionAfterExpandedDeletion return n…
Browse files Browse the repository at this point in the history
…ull for collapsed selections (Resolves #2431) (#2436)
  • Loading branch information
angelosilvestre authored Dec 11, 2024
1 parent d1a173d commit 90f4fe0
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1396,6 +1396,13 @@ class CommonEditorOperations {
}) {
// Figure out where the caret should appear after the
// deletion.

if (selection.isCollapsed) {
// There is no expanded deletion when the selection is collapsed. Therefore,
// no selection change is expected.
return null;
}

// TODO: This calculation depends upon the first
// selected node still existing after the deletion. This
// is a fragile expectation and should be revisited.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,29 @@ void main() {
);
});
});

group('getDocumentPositionAfterExpandedDeletion', () {
test('returns null for collapsed selection', () {
final node = HorizontalRuleNode(
id: "1",
);

expect(
CommonEditorOperations.getDocumentPositionAfterExpandedDeletion(
document: MutableDocument(nodes: [
node,
]),
selection: DocumentSelection.collapsed(
position: DocumentPosition(
nodeId: node.id,
nodePosition: node.endPosition,
),
),
),
isNull,
);
});
});
});
}

Expand Down

0 comments on commit 90f4fe0

Please sign in to comment.