Skip to content

add Cmd/Option+Up/Down shortcuts in source editor on macOS#15371

Merged
Siedlerchr merged 2 commits into
JabRef:mainfrom
AnvitaPrasad:fix-macos-vertical-cursor-shortcuts
Mar 19, 2026
Merged

add Cmd/Option+Up/Down shortcuts in source editor on macOS#15371
Siedlerchr merged 2 commits into
JabRef:mainfrom
AnvitaPrasad:fix-macos-vertical-cursor-shortcuts

Conversation

@AnvitaPrasad

@AnvitaPrasad AnvitaPrasad commented Mar 19, 2026

Copy link
Copy Markdown
Contributor

Related issues and pull requests

Closes #5937
Follow-up to #15358

PR Description

This PR extends macOS cursor navigation in the BibTeX source editor to cover vertical shortcuts. Command+Up/Down now moves the cursor to the document start/end, and Option+Up/Down moves to the paragraph start/end. All shortcuts also support Shift for selection extension.

Steps to test

  1. Use macOS
  2. Start JabRef from this branch
  3. Open any .bib library and select an entry
  4. Go to the Source tab in the entry editor
  5. Place the cursor somewhere in the middle of the source text
  6. Press Command+Up → cursor should jump to the very beginning of the document
  7. Press Command+Down → cursor should jump to the very end of the document
  8. Press Option+Up → cursor should jump to the start of the current paragraph
  9. Press Option+Down → cursor should jump to the end of the current paragraph
  10. Hold Shift with any of the above to verify selection extension works
Screen.Recording.2026-03-19.at.2.35.23.PM.mov

Checklist

  • I own the copyright of the code submitted and I license it under the MIT license
  • I manually tested my changes in running JabRef (always required)
  • I added JUnit tests for changes (if applicable)
  • I added screenshots in the PR description (if change is visible to the user)
  • [/] I added a screenshot in the PR description showing a library with a single entry with me as author and as title the issue number
  • I described the change in CHANGELOG.md in a way that can be understood by the average user (if change is visible to the user)
  • [/] I checked the user documentation for up to dateness and submitted a pull request to our user documentation repository

Copilot AI review requested due to automatic review settings March 19, 2026 09:11
@qodo-free-for-open-source-projects

Copy link
Copy Markdown
Contributor

Review Summary by Qodo

Add macOS vertical cursor navigation shortcuts to source editor

✨ Enhancement

Grey Divider

Walkthroughs

Description
• Add vertical cursor navigation shortcuts for macOS source editor
  - Command+Up/Down move to document start/end
  - Option+Up/Down move to paragraph start/end
• Support Shift variants for selection extension
• Refactor horizontal shortcut handling for better code organization
• Add comprehensive unit tests for new vertical navigation shortcuts
Diagram
flowchart LR
  A["macOS Key Events<br/>Up/Down Keys"] -->|"Command+Up/Down"| B["Document<br/>Start/End"]
  A -->|"Option+Up/Down"| C["Paragraph<br/>Start/End"]
  A -->|"Shift Variants"| D["Selection<br/>Extension"]
  B --> E["CodeArea Navigation"]
  C --> E
  D --> E
Loading

Grey Divider

File Changes

1. jabgui/src/main/java/org/jabref/gui/keyboard/CodeAreaKeyBindings.java ✨ Enhancement +27/-12

Add vertical cursor navigation shortcuts for macOS

• Refactored key code validation to separately check horizontal and vertical arrow keys
• Restructured conditional logic to handle vertical shortcuts (Up/Down) alongside existing
 horizontal shortcuts
• Added support for Command+Up/Down to move cursor to document start/end
• Added support for Option+Up/Down to move cursor to paragraph start/end
• Maintained Shift modifier support for selection extension on all new shortcuts

jabgui/src/main/java/org/jabref/gui/keyboard/CodeAreaKeyBindings.java


2. jabgui/src/test/java/org/jabref/gui/keyboard/CodeAreaKeyBindingsTest.java 🧪 Tests +67/-1

Add tests for vertical cursor navigation shortcuts

• Added test for Command+Up moving cursor to document start
• Added test for Command+Down moving cursor to document end
• Added test for Option+Up moving cursor to paragraph start
• Added test for Option+Down moving cursor to paragraph end
• Added test for Shift+Command+Up extending selection to document start
• Added test for Shift+Command+Down extending selection to document end
• Updated existing non-arrow key test to use KeyCode.A instead of KeyCode.UP

jabgui/src/test/java/org/jabref/gui/keyboard/CodeAreaKeyBindingsTest.java


3. CHANGELOG.md 📝 Documentation +1/-0

Document vertical cursor navigation shortcut fixes

• Added entry documenting the fix for vertical cursor movement shortcuts on macOS
• Entry covers Command+Up/Down and Option+Up/Down functionality
• References issue #5937

CHANGELOG.md


Grey Divider

Qodo Logo

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Mar 19, 2026

Copy link
Copy Markdown
Contributor

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 📐 Spec deviations (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

Copilot AI 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.

Pull request overview

Adds macOS-standard vertical cursor navigation shortcuts to the BibTeX source editor’s CodeArea handling, completing the macOS cursor movement behavior started in #15358.

Changes:

  • Extend macOS cursor shortcut handler to support Command+Up/Down (document start/end) and Option+Up/Down (paragraph start/end), including shift-selection via the existing selection policy.
  • Add JUnit tests covering the new vertical shortcuts (and shift-selection for the Command variants).
  • Document the fix in CHANGELOG.md.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
jabgui/src/main/java/org/jabref/gui/keyboard/CodeAreaKeyBindings.java Implements macOS vertical navigation handling for Command/Option + Up/Down in the source editor.
jabgui/src/test/java/org/jabref/gui/keyboard/CodeAreaKeyBindingsTest.java Adds tests validating the new vertical shortcut behaviors.
CHANGELOG.md Adds an Unreleased “Fixed” entry describing the macOS vertical shortcut fix.

You can also share your feedback on Copilot code review. Take the survey.

assertTrue(event.isConsumed());
}

@Test
@github-actions github-actions Bot added the status: changes-required Pull requests that are not yet complete label Mar 19, 2026
@AnvitaPrasad AnvitaPrasad force-pushed the fix-macos-vertical-cursor-shortcuts branch from c5460c9 to 5599ab4 Compare March 19, 2026 09:34
@github-actions github-actions Bot added status: no-bot-comments and removed status: changes-required Pull requests that are not yet complete labels Mar 19, 2026
@jabref-machine

Copy link
Copy Markdown
Collaborator

Hey, we noticed that you force-pushed your changes. Force pushing is a bad practice when working together on a project (mainly because it is not supported well by GitHub itself). Commits are lost and comments on commits lose their context, thus making it harder to review changes.

When the pull request is getting integrated into main, all commits will be squashed anyway. Thus, your individual commit history will not be visible in main.

In future, please avoid that. For now, you can continue working.

@github-actions github-actions Bot added status: changes-required Pull requests that are not yet complete and removed status: no-bot-comments labels Mar 19, 2026
@testlens-app

testlens-app Bot commented Mar 19, 2026

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: 5599ab4
▶️ Tests: 10203 executed
⚪️ Checks: 53/53 completed


Learn more about TestLens at testlens.app.

@Siedlerchr Siedlerchr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Works as expected! Thanks for the follow up!

@Siedlerchr Siedlerchr added this pull request to the merge queue Mar 19, 2026
@github-actions github-actions Bot added the status: to-be-merged PRs which are accepted and should go into the merge-queue. label Mar 19, 2026
Merged via the queue into JabRef:main with commit c8efcc0 Mar 19, 2026
51 of 53 checks passed
FynnianB pushed a commit to FynnianB/jabref that referenced this pull request Mar 19, 2026
)

* add Cmd/Option+Up/Down shortcuts in source editor on macOS

* add missing Shift+Option+Up/Down tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: ui status: changes-required Pull requests that are not yet complete status: to-be-merged PRs which are accepted and should go into the merge-queue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Text cursor movement shortcuts do not work correctly on macOS

4 participants