Skip to content

fix: correct Ctrl+J/K movement when image block is focused#76

Merged
j4rviscmd merged 1 commit intomainfrom
fix/vim-fix-image
Mar 27, 2026
Merged

fix: correct Ctrl+J/K movement when image block is focused#76
j4rviscmd merged 1 commit intomainfrom
fix/vim-fix-image

Conversation

@j4rviscmd
Copy link
Copy Markdown
Owner

Summary

  • Fix Ctrl+K (up) and Ctrl+J (down) not moving the cursor when an image (or other file) block has focus
  • Root cause: NodeSelection (used when an atomic block is selected) keeps $head at the node's trailing position; calling Selection.findFrom($head, -1) re-selected the same node instead of jumping to the previous block
  • Fix: detect NodeSelection via instanceof and resolve a position just outside the node ($head.after/$head.before at the node depth) before calling findFrom, consistent with the existing textblock-boundary logic

Changes

File Description
src/features/editor/lib/cursorVimKeys.ts Add NodeSelection import; special-case node selections in vertical movement

Reproduction

  1. Insert an image block
  2. Click the image to focus it (creates a NodeSelection)
  3. Press Ctrl+K — cursor should move to the block above (was stuck before this fix)

NodeSelection (used for image/file blocks) keeps $head at the node's
end position, so Selection.findFrom($head, dir) was re-selecting the
same node instead of jumping to the neighbour block.

Detect NodeSelection with instanceof and resolve a position just outside
the node ($head.after/before at the node's depth) before calling
findFrom, matching the existing textblock-boundary behaviour.
@j4rviscmd j4rviscmd added the bug Something isn't working label Mar 27, 2026
@j4rviscmd j4rviscmd merged commit 9421d08 into main Mar 27, 2026
2 checks passed
@j4rviscmd j4rviscmd deleted the fix/vim-fix-image branch March 27, 2026 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant