Skip to content

Writing flow: merge partial text selections across nesting boundaries instead of deleting the whole block #80489

Description

@ellatrix

What problem does this address?

Follow up to #80462, which made a text selection crossing a nesting boundary (e.g. from the middle of a list item into the middle of its own nested item) select the outer block fully, so Backspace/Delete removes it as a whole.

That is the conservative behavior: exactly what is highlighted gets deleted. But a plain text editor would delete only the selected characters and merge the remainder. Given:

• ab      ← selection starts after "a"
   ◦ cd   ← selection ends after "c"

pressing Backspace would ideally produce a single item "ad", not delete the whole "ab" item.

What is your proposed solution?

Refine the deletion of cross-nesting selections to a real merge. The correct rule, in document order within the outer block: delete everything before the selection-end block, delete the selection-end block itself but keep its children, keep everything after it. For example, unselected content must survive:

  • the end block's own nested children ("ef" under "cd"),
  • unselected following siblings of the end block ("xy" after "cd").

#78771 explores this direction (store-level support in __unstableIsSelectionMergeable / __unstableDeleteSelection); it predates #80462 and needs reworking on top of it. #78776 established the equivalent behavior for sibling list items.

Also worth deciding as part of this: what Enter and typing over such a selection should do (currently safe no-ops).

Related but separate: extending a selection into a nested line with Shift+ArrowDown is a native no-op, and drag selections across nesting boundaries record incorrectly in some shapes; those are selection-gesture bugs independent of the delete semantics.

Metadata

Metadata

Assignees

Labels

[Feature] Writing FlowBlock selection, navigation, splitting, merging, deletion...[Status] In ProgressTracking issues with work in progress[Type] EnhancementA suggestion for improvement.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions