Skip to content

fix: make Backspace and Delete on a message's blank line replace only that line - #7185

Merged
leaf-agent merged 2 commits into
mainfrom
fix/issue-7174
Nov 25, 2026
Merged

leaf-agent merged 2 commits into
mainfrom
fix/issue-7174

Conversation

@leaf-agent

Copy link
Copy Markdown
Collaborator

Since #7117, Backspace and Delete on a message's blank line propose an edit that runs from the end of the paragraph above, so the draft check (keeps) sees the blocks the edit joins. deleteAtEdge dispatched that wide edit as written. CodeMirror then rewrote every blank line between the paragraph and the caret with the children they already had, and the teardown's write watch failed both desktop delete cases of tests/journeys/test_thread_response_continuity.py::test_native_reply_edits_after_semantic_paint_keep_the_first_line with unchanged write: children of div.cm-content.cm-lineWrapping.

deleteAtEdge still checks the wide edit. It now dispatches the edit without the source the edit puts back as it was (narrowed in field-editor.js), so the field replaces only the line the key takes. The draft and the caret after the key don't change, since the resulting document is the same. No user-visible behaviour changes apart from the DOM writes that go away.

Verification:

  • All 8 cases of the journey test pass. On main (32dc564a8) both *-delete-desktop cases error at teardown.
  • A new runtime test, "a key taking a message's blank line replaces only that line", fails without the fix and passes with it. pnpm run test:runtime passes 1132 of 1132.
  • pnpm run check:browser and test_a_draft_nests_its_blocks_as_its_sent_message_does pass.

Closes #7174 — automated triage

… that line

#7117 made Backspace and Delete on a message's blank line propose an edit
that runs from the end of the paragraph above, so `keeps` sees the blocks
it joins. The editor dispatched that edit as written, so CodeMirror
rewrote every blank line between the paragraph and the caret with the
same children, which the teardown's write watch reports as an unchanged
write in both desktop delete cases of
test_native_reply_edits_after_semantic_paint_keep_the_first_line.

deleteAtEdge still checks the wide edit and now dispatches it without the
source the edit puts back as it was, so the field replaces only the line
the key takes. The draft and the caret after the key are as before. A
runtime test asserts that each key replaces only its line.

Closes #7174
@max-sixty

Copy link
Copy Markdown
Owner

@leaf-agent The fix works, but fieldState in this file already computes the same common-prefix and nonoverlapping common-suffix edit (base lines 2743–2754 and 3015). Please extract that calculation once and use it for both fieldState and narrowed, so selection restoration and redraw trimming do not maintain two copies.

This was written by Codex on behalf of max-sixty

…and narrowed

fieldState and narrowed each computed the edit between two strings' longest
common prefix and the non-overlapping common suffix. Both now call one
module-level helper, differing. No behaviour changes.
@leaf-agent

Copy link
Copy Markdown
Collaborator Author

Done in d5ade73. A module-level differing(was, put, at) in field-editor.js now computes the edit between the common prefix and the non-overlapping common suffix. fieldState uses it for the history step and the caret it restores, and narrowed calls it once per change. Nothing else changes.

pnpm run test:runtime passes 1132 of 1132, including the new blank-line test. check:browser and eslint pass.

@leaf-agent
leaf-agent merged commit f542b61 into main Nov 25, 2026
7 checks passed
@leaf-agent
leaf-agent deleted the fix/issue-7174 branch November 25, 2026 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test_native_reply_edits_after_semantic_paint_keep_the_first_line: unchanged write of the reply editor's content since #7117

2 participants