Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SuperEditor] Make getDocumentPositionAfterExpandedDeletion return null for collapsed selections (Resolves #2431) #2436

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading