Skip to content

feat(review): go to definition (d), back and forward (ctrl+o, ctrl+i) - #178

Merged
backnotprop merged 2 commits into
mainfrom
feat/jump-to-definition
Nov 20, 2026
Merged

backnotprop merged 2 commits into
mainfrom
feat/jump-to-definition

Conversation

@backnotprop

@backnotprop backnotprop commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Adds go to definition to the code review screen, on top of the search core from #169 (codenav).

  • d on a line of the diff or of the whole-file view takes the identifiers on that line (identifiers_on_line). With one, it searches at once. With several, a small list shows them left to right; 1-9 or Enter picks one, Esc closes.
  • The search runs on its own thread with the core's time limit (codenav::search, 5 s), so the screen never waits. The footer says searching for <word>… while it runs.
  • Side: the diff's new side searches the reviewed version (work tree, index or commit). The old side and the base view search the base. A renamed file's old path is used on the base.
  • One clear answer is jumped to: a single definition other than the line itself, or, with no definition, a single use (the target is Found::best). It lands in the diff when the diff shows that line, otherwise in the whole-file view of that file at that line (the current file, or the base view when the base was searched).
  • Several answers open a list with path:line, definition/use and the line text, in the core's ranking order. Enter goes there, Esc closes.
  • Nothing found: the footer says no definition or use of <word> found (plus "in the base", and "the search stopped early" when the core stopped early).
  • ctrl+o goes back to where you jumped from, and ctrl+i goes forward again. The history keeps 30 places (file, diff or whole-file view and its side, line). ctrl+i needs a terminal that tells it apart from Tab; where it arrives as Tab, Tab keeps cycling the focus as before.
  • Works in pull request reviews, including PRs fetched into the bare cache repository with no clone: both sides are the PR's commits.

Keys: go-to-definition = d, jump-back = ctrl+o, jump-forward = ctrl+i, in the diff (and so in the whole-file view). All three are in the "late" list, so an older config that already uses those keys keeps them. d is still the block mark in document reviews. README (key table, code review keys, a paragraph under Code review) and the help screen are updated.

The help screen had grown taller than a 34-row terminal and was being cut off. It now scrolls with j/k (the bottom border says so) when it does not fit, and splits into two columns when the terminal is wide enough.

Tests: review/tests/jump_flow.rs covers one answer in the diff with ctrl+o and ctrl+i; the word list and a definition outside the diff opening the whole file; the answer list with Enter and Esc; nothing found; a base search landing in the base view; and the help. pull_flow.rs searches both sides of a PR from the cache repository. There are also unit tests for the history and the keymap.

Also fixes the core's identifier scan (codenav.rs, separate commit). It used to skip a JavaScript/TypeScript template literal whole, so return `${name} ${formatPrice(cents)}`; offered nothing. It now skips only the literal's text and reads the code inside each ${…}, handling nested braces, strings and templates; an escaped \${ stays text. Tests are in codenav/tests.rs.

Rebased onto #177. The lists and the whole-file view use the full width when the notes rail is closed, which jump_flow.rs tests.

@backnotprop
backnotprop added this pull request to the merge queue Nov 20, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Nov 20, 2026
@backnotprop
backnotprop force-pushed the feat/jump-to-definition branch from 1c5a594 to 7ff3c31 Compare November 20, 2026 04:34
d on a line of the diff or the whole-file view searches for the identifier on
it with the codenav core, on a thread of its own, on the side the cursor is on:
the new side searches the reviewed version, the old side and the base view the
base. Several identifiers on the line are offered in a small list. One clear
answer is jumped to, in the diff when it shows that line, otherwise in the
whole-file view on the searched side; several are listed with path:line, kind
and the line text in the core's order. Nothing found says so in the footer,
and "searching for ..." shows while the search runs.

ctrl+o goes back to the place jumped from and ctrl+i forward again, over a
history of 30 places. The key help scrolls with j/k when it does not fit, and
splits into two columns when the terminal is wide enough.
…t template literals

The identifier scan skipped a template literal whole. It now skips only the
literal's text and reads the code in each substitution, with nested braces,
strings and templates; an escaped \${ stays text.
@backnotprop
backnotprop force-pushed the feat/jump-to-definition branch from 7ff3c31 to fa17837 Compare November 20, 2026 04:39
@backnotprop
backnotprop added this pull request to the merge queue Nov 20, 2026
Merged via the queue into main with commit 34c238a Nov 20, 2026
3 checks passed
@backnotprop
backnotprop deleted the feat/jump-to-definition branch November 20, 2026 04:50
@backnotprop backnotprop mentioned this pull request Nov 23, 2026
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