Skip to content

fix(editor): Alt+Shift+Up/Down right after Enter moves the new block - #13601

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

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

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 end of c, press Enter (a new empty block under c, the cursor in it), then press Alt+Shift+Down right away. c moves below the new empty block, which stays where it was with the cursor in it: the page reads a, b, (empty), c, d, e instead of a, b, c, d, (empty), e. Alt+Shift+Up the same way moves c above b instead of moving the new block above c.

Enter inserts the new block in steps that each wait on the db worker; only the last one moves the editor to the new block. Until then the edit state still names the block Enter split, and a move pressed in between moves that block.

The pending Enter (start-pending-new-block! / clear-pending-new-block!) now carries a promise that settles when it has moved the editor, or failed, and move-up-down waits for it before it takes the edited block. Without an Enter pending, the move starts as before.

Measured with real key events, 8 tries per direction, the move key a fixed time after Enter: before, 16 of 16 presses moved the wrong block at 20 ms, 3 of 16 at 40 ms. After, 0 of 16 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

Enter inserts the new block in steps that wait on the db worker; only
the last one moves the editor to it. A move pressed before that took
the block Enter split as the edited one and moved it: Enter at the end
of c, then Alt+Shift+Down within ~40 ms, moved c below the new empty
block, which stayed in place with the cursor in it; Alt+Shift+Up moved
c above b.

The pending Enter now carries a promise that settles when it has moved
the editor (or failed), 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
…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.

@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 1 potential issue.

Devin Review

Comment on lines +325 to +327
(let [resolve! (atom nil)
done (p/create (fn [resolve _reject] (reset! resolve! resolve)))]
(reset! *pending-new-block-done {:promise done :resolve! @resolve!}))

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.

🔴 Block moves freeze after navigation

Navigating away during Enter leaves <pending-new-block unresolved when the transaction skips its editor callback. Later move shortcuts wait forever, even after insertion finishes.

Learn more

The pending promise is created for each insertion and normally resolved by clear-pending-new-block! in the editor callback. apply-outliner-ops suppresses that callback when the request's graph or route differs from the current context. The successful insert then finishes without clearing the pending promise, and every later move waits on it. The editor's pending state also remains set, blocking future Enter presses until another cleanup path runs.

Example: Press Enter on page A, switch to page B before the worker replies, then press Alt+Shift+Down on page B. The worker finishes the insertion on A without invoking its editor callback, so the shortcut on B never runs.

Recommended fix: Settle the insertion's own promise in a completion handler when its transaction ends without executing the editor callback. Couple the promise to its insertion/context and clear the associated pending editor state when abandoning that context; avoid resolving a newer insertion from an older completion.

Devin Review


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

@yuxi-liu-wired

Copy link
Copy Markdown
Contributor Author

Replaced by #13603, which fixes this and #13600 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
…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
…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
…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
…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-enter 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