fix(track-changes): allow backspace on empty list items in suggesting mode (SD-2187)#2472
fix(track-changes): allow backspace on empty list items in suggesting mode (SD-2187)#2472
Conversation
… mode (SD-2187) When all text in a list item was deleted in suggesting mode (marked as trackDelete), pressing backspace to remove the bullet did nothing. The replaceAroundStep handler blocked the structural change because findPreviousLiveCharPos returned null (no un-deleted text left). Allow the structural ReplaceAroundStep (e.g. lift out of list) to apply when there are no live characters remaining. Structural changes aren't tracked yet, but blocking them leaves the user stuck on an empty bullet they can't remove.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4cc21ad078
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if (deleteFrom === null) { | ||
| // No live character found — nothing to delete. Skip the structural change. | ||
| // No live character to delete — the list item / block is effectively empty | ||
| // (all content already tracked-deleted). Allow the structural change | ||
| // (e.g. lifting out of list) to apply directly. Structural changes aren't | ||
| // tracked yet, but blocking them leaves the user stuck on an empty bullet | ||
| // they can't remove (SD-2187). | ||
| if (!newTr.maybeStep(step).failed) { |
There was a problem hiding this comment.
Keep structural backspace blocked on non-empty items
This branch now treats deleteFrom === null as “effectively empty”, but findPreviousLiveCharPos() only looks at text before the caret. When the caret is at the start of a non-empty list item in suggesting mode, deleteFrom is also null, so pressing Backspace will apply the original ReplaceAroundStep untracked and lift/outdent the item, dropping list/paragraph properties instead of preserving them as tracked text changes. The direct structural step needs an additional check that the whole block/list item is already fully deleted, not just that there is no live character before the cursor.
Useful? React with 👍 / 👎.
Demo
CleanShot.2026-03-19.at.15.20.55.mp4
Summary
replaceAroundStephandler blocked structural changes (e.g. lift out of list) whenfindPreviousLiveCharPosreturned null, leaving the user stuck on an undeletable empty bulletReplaceAroundStepto apply directly instead of blocking itRoot Cause
The
replaceAroundStephandler (introduced in PR #2225 / SD-2061) converts backspaceReplaceAroundStepoperations into tracked single-character deletions. When all text in a list item is already marked astrackDelete,findPreviousLiveCharPos()returnsnulland the handler returned early, blocking the structural change entirely.The fix allows the structural step to pass through when the content is effectively empty. Structural changes aren't tracked yet (as noted in the ticket), but blocking them is worse than applying them untracked.
Test plan