Skip to content

feat: add Jump Back / Jump Forward to navigate the jump history - #388

Merged
RoiSoleil merged 2 commits into
masterfrom
feat/jump-back-forward
Sep 24, 2026
Merged

RoiSoleil merged 2 commits into
masterfrom
feat/jump-back-forward

Conversation

@RoiSoleil

Copy link
Copy Markdown
Contributor

What

Adds Jump Back (Ctrl+Alt+Shift+←) and Jump Forward (Ctrl+Alt+Shift+→): navigate back and forward between the locations visited when jumping between a class under test and its test case (and vice versa), the way a web browser does.

Every jump (keyboard shortcut, editor / package explorer menus, code mining clicks) now remembers where the user jumped from:

  • Jump Back returns to the previous location, restoring the exact cursor position
  • Jump Forward goes forward again after having jumped back
  • a new jump resets the forward history (browser behavior), consecutive duplicates are ignored, history is capped at 50 locations
  • both actions are also available in the editor's MoreUnit contextual menu, and their shortcut is configurable in Preferences → Keys

Typical flow: Ctrl+Shift+J to the test method, write the test, Jump Back to continue coding the method under test at the exact place you left.

How

  • new org.moreunit.navigation package: JumpLocation (compilation unit + offset) and JumpNavigationHistory (back/forward stacks, browser semantics)
  • JumpActionExecutor registers every performed jump and executes the back/forward commands — for all jump entries: JumpCodeMining now delegates its jump to it instead of duplicating the code, so code mining jumps are followed too
  • EditorUI.revealOffset(...) restores the cursor position when navigating
  • EditorPartFacade.getTextSelection() is now null-safe (returns null instead of throwing when the editor has no text selection)

Testing

  • 18 new unit tests: JumpNavigationHistoryTest (12) and JumpLocationTest (6)
  • 4 new scenarios in JumpActionExecutorTest: jump registration (from editor and from package explorer entry points), back/forward round trip with cursor position restore, no-op when the history is empty
  • 1 new SWTBot test (JumpNavigationTest) exercising the whole flow with the real shortcuts (jump → back → forward, asserting the editor and the cursor line), plus ShortcutStrategy.pressJumpBack/ForwardShortcut()
  • full unit test run: 2043 tests, 0 failure (core.test 666, test 922, mock.test 433, mock.it 22)

⚠️ On my Linux/Wayland workstation, no SWTBot test can run (even unmodified BasicJumpTest fails there identically, with or without this branch), so JumpNavigationTest is expected to be exercised by the CI (windows-latest) only.

Documentation

help/documentation.html documents the new shortcuts next to the existing "Switching between test and class under test" section.

Every jump between a class under test and its test case (shortcut, editor/package explorer menus or code mining) now remembers the location it was made from. The new commands "Jump Back" (Ctrl+Alt+Shift+ARROW_LEFT) and "Jump Forward" (Ctrl+Alt+Shift+ARROW_RIGHT) navigate in this history the way a web browser does, restoring the exact cursor position. Both are also available in the editor MoreUnit menu, and their shortcut can be configured in Preferences > Keys.

JumpCodeMining now delegates its jump to JumpActionExecutor instead of duplicating it, so that every jump is registered in the history. EditorPartFacade.getTextSelection() has become null-safe.
Unit tests for JumpNavigationHistory and JumpLocation, jump registration and back/forward scenarios in JumpActionExecutorTest (including cursor position restore and empty history), plus a SWTBot test exercising the whole flow with the real shortcuts.
@RoiSoleil
RoiSoleil force-pushed the feat/jump-back-forward branch 2 times, most recently from abc27d9 to daa425e Compare September 24, 2026 13:32
@RoiSoleil
RoiSoleil merged commit e52cce4 into master Sep 24, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant