Skip to content

fix(editor): Alt+Shift+Up/Down right after a Backspace join moves the joined block - #13600

Closed
yuxi-liu-wired wants to merge 1 commit into
logseq:masterfrom
yuxi-liu-wired:fix/move-after-backspace-join
Closed

yuxi-liu-wired wants to merge 1 commit into
logseq:masterfrom
yuxi-liu-wired:fix/move-after-backspace-join

Conversation

@yuxi-liu-wired

@yuxi-liu-wired yuxi-liu-wired commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

On a page with blocks a, b, c, d, e: put the cursor at the start of d, press Backspace (d joins c, the cursor is in "cd"), then press Alt+Shift+Down right away. Nothing moves: the page stays a, b, cd, e. Alt+Shift+Up does the same. A second press moves the block.

Backspace at the start of a block joins it into the block above in several steps that each wait on the db worker; only the last one moves the editor to the joined block. Until then the edit state still names the deleted block. A move pressed in between loads that block (gone by then), sends a move for it, and the worker moves nothing.

A running Backspace or Delete join (delete-block-inner!) is now recorded until it has moved the editor, and move-up-down waits for it before it takes the edited block. Without a join running, the move starts as before.

Measured with real key events, 12 tries per direction, the move key a fixed time after Backspace: before, 24 of 24 presses moved nothing at 20 ms, 2 of 24 at 40 ms. After, 0 of 24 at 0 ms, 20 ms and 40 ms each. frontend.handler.editor-test, frontend.handler.editor-async-test and frontend.handler.editor-lifecycle-test pass.


Devin Review

… joined block

Backspace at the start of a block joins it into the block above in
several steps that wait on the db worker; only the last one moves the
editor to the joined block. A move pressed before that (Backspace, then
Alt+Shift+Down within ~40 ms) took the deleted block as the edited one,
sent a move for it, and nothing moved.

A running Backspace or Delete join is now recorded until it has moved
the editor, and a move waits for it before it takes the edited block.
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 6, 2026
… joined block (logseq#13600)

The fork carries logseq#13600: a running Backspace or Delete join is recorded
until it has moved the editor; a move waits for it. The move log notes
when a move waited for a join.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 2 potential issues.

Devin Review

Comment on lines +982 to +985
(let [p (delete-block-inner-aux! repo editor-state)
;; settles when the join is done or failed, never rejects
settled (-> (p/resolved p) (p/catch (constantly nil)))]
(reset! *pending-block-delete settled)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Immediate moves still miss early joins

When Alt+Shift+Up/Down follows Backspace or Delete before delete-block-inner! starts, <pending-block-delete resolves immediately. Both key handlers await earlier worker reads, so the move can still target the deleted block and do nothing.

Learn more

The promise is registered only after delete-block-inner-aux! begins. Backspace first awaits <left-sibling-or-parent in delete-block-when-zero-pos!, and Delete first awaits two block loads in delete-concat. During those waits, <pending-block-delete resolves immediately. A move launched then reads the old edit block and can race the pending deletion.

Example: At the start of block d, press Backspace and immediately Alt+Shift+Down while the left-sibling lookup is pending. The move sees no registered join and attempts to move d instead of the eventual merged block c.

Recommended fix: Register the entire eligible join operation before the first asynchronous preflight in delete-block-when-zero-pos! and delete-concat, then clear its tracking promise after the editor callback completes. Keep non-join key paths outside that gate.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +985 to +988
(reset! *pending-block-delete settled)
(p/then settled (fn [_]
(when (identical? @*pending-block-delete settled)
(reset! *pending-block-delete nil))))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Overlapping joins release moves too early

If two joins overlap, delete-block-inner! replaces the first pending promise with the second. A move after the second finishes can race the first join and target its outdated edit block.

Learn more

The atom stores one join, not the set or chain of in-flight joins. Overlapping Backspace/ Delete handlers can both call delete-block-inner! before either finishes. The most recent join's cleanup leaves the atom empty even when an earlier join remains outstanding. The earlier join can still delete a block or set editor focus while a new move is running.

Example: Start a slow Backspace join on one block, then a faster Delete join on another before the first finishes. Once the Delete join finishes, Alt+Shift+Down stops waiting although the Backspace join is still in flight.

Recommended fix: Track all outstanding joins, or serialize them in a promise chain; let <pending-block-delete wait for every join that was started before the move. Account for the preflight operations as well.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 6, 2026
…ogseq#13601)

The fork carries logseq#13601: the pending Enter carries a promise that
settles when it has moved the editor; a move waits for it (and for a
running Backspace/Delete join, logseq#13600). The move log notes either wait.
@yuxi-liu-wired

Copy link
Copy Markdown
Contributor Author

Replaced by #13603, which fixes this and #13601 in one change.

yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 6, 2026
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 8, 2026
… joined block (logseq#13600)

The fork carries logseq#13600: a running Backspace or Delete join is recorded
until it has moved the editor; a move waits for it. The move log notes
when a move waited for a join.
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 8, 2026
…ogseq#13601)

The fork carries logseq#13601: the pending Enter carries a promise that
settles when it has moved the editor; a move waits for it (and for a
running Backspace/Delete join, logseq#13600). The move log notes either wait.
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 8, 2026
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 11, 2026
… joined block (logseq#13600)

The fork carries logseq#13600: a running Backspace or Delete join is recorded
until it has moved the editor; a move waits for it. The move log notes
when a move waited for a join.
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 11, 2026
…ogseq#13601)

The fork carries logseq#13601: the pending Enter carries a promise that
settles when it has moved the editor; a move waits for it (and for a
running Backspace/Delete join, logseq#13600). The move log notes either wait.
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 11, 2026
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 13, 2026
… joined block (logseq#13600)

The fork carries logseq#13600: a running Backspace or Delete join is recorded
until it has moved the editor; a move waits for it. The move log notes
when a move waited for a join.
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 13, 2026
…ogseq#13601)

The fork carries logseq#13601: the pending Enter carries a promise that
settles when it has moved the editor; a move waits for it (and for a
running Backspace/Delete join, logseq#13600). The move log notes either wait.
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 13, 2026
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 16, 2026
… joined block (logseq#13600)

The fork carries logseq#13600: a running Backspace or Delete join is recorded
until it has moved the editor; a move waits for it. The move log notes
when a move waited for a join.
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 16, 2026
…ogseq#13601)

The fork carries logseq#13601: the pending Enter carries a promise that
settles when it has moved the editor; a move waits for it (and for a
running Backspace/Delete join, logseq#13600). The move log notes either wait.
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 16, 2026
@yuxi-liu-wired
yuxi-liu-wired deleted the fix/move-after-backspace-join branch October 21, 2026 18:02
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.

1 participant