Repository navigation
fix(editor): Alt+Shift+Up/Down right after Enter moves the new block - #13601
yuxi-liu-wired wants to merge 1 commit into
Conversation
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.
…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.
| (let [resolve! (atom nil) | ||
| done (p/create (fn [resolve _reject] (reset! resolve! resolve)))] | ||
| (reset! *pending-new-block-done {:promise done :resolve! @resolve!})) |
There was a problem hiding this comment.
🔴 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.
Was this helpful? React with 👍 or 👎 to provide feedback.
…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.
…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.
…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.
…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.
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, andmove-up-downwaits 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-testandfrontend.handler.editor-lifecycle-testpass.