Fix(editor): arrow keys navigate the @, / and [[ menus again - #707
Open
ArditZubaku wants to merge 4 commits into
Open
Fix(editor): arrow keys navigate the @, / and [[ menus again#707ArditZubaku wants to merge 4 commits into
ArditZubaku wants to merge 4 commits into
Conversation
… completion keymap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Arrow keys navigate an open completion menu again — the
@date/note suggestions, the/slash menu, the[[reference picker and the callout[!type picker. Before this, ↑/↓ moved the caret instead, and the caret move closed the menu, so the only way to pick an item was Ctrl+N/Ctrl+P.Why it broke
autocompletion({ defaultKeymap: false })skips the stock completion keymap so mac AltGr-style layouts keep theirAlt-`/Alt-icharacters. The filtered replacement (completionKeymapForEditor) was re-added by spreading it into the editor's generalkeymap.of([...]).Upstream mounts that keymap at
Prec.highest. The spread put it at default precedence and last in the array — and CodeMirror runs same-key bindings in array order (buildKeymappushes ontobinding.run). SodefaultKeymap'sArrowUp/ArrowDown(cursorLineUp/cursorLineDown) ran first, returnedtrue, and the completion never saw the key.EditorPaneandPinnedReferencePanespread it last, so they were broken.QuickCaptureAppandTemplateEditorModalhappened to spread it first, so they worked — which is why the behaviour differed between the main editor and the Quick Note window.The fix
A new
completionKeymapExtensionmounts the same filtered bindings atPrec.highest, matching what@codemirror/autocompletedoes for its own keymap. All four editors mount it next tocompletionNavKeymapinstead of inlining the spread, which removes the ordering trap for future edits.No behaviour change for the AltGr fix — the two mac chords stay filtered out.
Testing
cm-completion-nav-arrows.test.ts: ↓↓↑ moves the highlighted option, the menu stays open and the caret does not move; with no menu open the arrows fall through to the next binding.npm run typecheck,npm run test:run(1827 passed) andnpm run buildall pass locally on Node 22.Before / After
Before — ↓ moves the caret and the
@menu closes.before.mov
After — ↓/↑ move the highlighted item, the menu stays open.
after.mov