Skip to content

Desktop: Improve macOS word navigation with Option+Arrow#15165

Open
MANVENDRA-github wants to merge 4 commits intolaurent22:devfrom
MANVENDRA-github:fix/15149-macos-word-navigation
Open

Desktop: Improve macOS word navigation with Option+Arrow#15165
MANVENDRA-github wants to merge 4 commits intolaurent22:devfrom
MANVENDRA-github:fix/15149-macos-word-navigation

Conversation

@MANVENDRA-github
Copy link
Copy Markdown
Contributor

Fixes #15149

Problem:
Joplin uses CodeMirror for editing, which does not automatically respect macOS system keybindings. As a result, standard macOS shortcuts like Option + Arrow may not behave consistently for word navigation.

Solution:
Adds a macOS-specific keymap override that maps:

  1. Option + Right - move to next word
    2 Option + Left - move to previous word

@coderabbitai coderabbitai Bot added enhancement Feature requests and code enhancements desktop All desktop platforms editor macOS markdown-editor About the Markdown editor labels Apr 20, 2026
@github-actions github-actions Bot deleted a comment from coderabbitai Bot Apr 20, 2026
Comment on lines +38 to +39
{ key: 'Alt-ArrowRight', run: cursorGroupRight },
{ key: 'Alt-ArrowLeft', run: cursorGroupLeft },
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Note: Based on the documentation, it looks like this should be part of the standard CodeMirror keymap extension.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/editor/CodeMirror/configFromSettings.ts`:
- Line 32: The change introduced an unnecessary blank line before the function
configFromSettings; revert that whitespace-only edit so the function
declaration's surrounding spacing matches the original style. Locate the
configFromSettings function in packages/editor/CodeMirror/configFromSettings.ts
and remove the extra newline so there are no added blank lines or
formatting-only changes.
- Line 13: Remove the duplicate registration of standardKeymap: delete the
import of standardKeymap from '@codemirror/commands' in configFromSettings.ts
and remove any code that adds standardKeymap to the keymap there (leave
defaultKeymap and emacsStyleKeymap as needed); createEditor.ts already registers
...standardKeymap in keymapConfig (Prec.low), so eliminating the import and
registration here prevents duplicate bindings and preserves intended precedence.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 5f6a47b2-3f88-4aa2-b17b-86444037afcd

📥 Commits

Reviewing files that changed from the base of the PR and between 30b11d3 and 31a933d.

📒 Files selected for processing (1)
  • packages/editor/CodeMirror/configFromSettings.ts

Comment thread packages/editor/CodeMirror/configFromSettings.ts Outdated
Comment thread packages/editor/CodeMirror/configFromSettings.ts Outdated
@github-actions github-actions Bot deleted a comment from coderabbitai Bot Apr 21, 2026
@github-actions github-actions Bot deleted a comment from coderabbitai Bot Apr 21, 2026
@personalizedrefrigerator
Copy link
Copy Markdown
Collaborator

personalizedrefrigerator commented Apr 21, 2026

As a result, standard macOS shortcuts like Option + Arrow may not behave consistently for word navigation.

The linked issue seems to be about command+arrow (configured via a DefaultKeyBinding.dict file), not option+arrow. Is option+arrow also broken?

@MANVENDRA-github
Copy link
Copy Markdown
Contributor Author

yeah option+arrow also seems to be broken lemme do a check and get back to you on this
i might have to properly go thru the doc aswell

@MANVENDRA-github
Copy link
Copy Markdown
Contributor Author

I tested this on macOS (Tahoe 26.3.1) to verify the reported behavior of cmd + arrow and also the behavior of option + arrow.

In joplin:
option + arrow performs word navigation as expected (the CodeMirror default behavior) and cmd + arrow moves to the end of the line
I also created a ~/Library/Keybindings/DefaultKeyBinding.dict override to remap cmd + arrow to word navigation as the user mentioned he was doing
This override did not take effect even in native apps like TextEdit on my setup

Given this, it appears that:

option + arrow is functioning correctly
The expectation around cmd + arrow relies on macOS keybinding overrides that are not consistently applied, and in any case are not integrated into CodeMirror’s key handling

So this doesnt seem to be an issue specific to joplin its more of a feature request

Based on this, I’ve removed the previously added keymap changes (including the redundant standardKeymap registration) to align with CodeMirror’s default behavior and avoid introducing conflicts.

let me know if you’d like me to take a different approach here or if this should be treated as a separate feature discussion.

I have also asked the user for their macos version coz it seems to me that the DefaultKeyBinding.dict doesnt work properly in newer ones

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

desktop All desktop platforms editor enhancement Feature requests and code enhancements macOS markdown-editor About the Markdown editor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Keyboard shortcut for moving cursor to word/line end / respect defaultkeybinding.dict on macos

2 participants