Skip to content

Add Cmd+Click go-to-definition in code viewer#1

Draft
davegaeddert wants to merge 2 commits into
masterfrom
cmd-click-go-to-definition
Draft

Add Cmd+Click go-to-definition in code viewer#1
davegaeddert wants to merge 2 commits into
masterfrom
cmd-click-go-to-definition

Conversation

@davegaeddert

Copy link
Copy Markdown
Member

Summary

  • Cmd+Click on a symbol in the diff or file viewer navigates to its definition within the app
  • Uses git grep -l to quickly narrow candidate files, then parallel tree-sitter symbol extraction to find exact name matches
  • Single result navigates directly to the file/line; multiple results show a picker dialog
  • Cmd+hover shows pointer cursor and underline styling via unsafeCSS injection into @pierre/diffs shadow DOM

Changes

Rust backend (3 modified files)

  • SymbolDefinition struct in symbols/mod.rs
  • find_definitions() helper in symbols/extractor.rs (recursive, includes children)
  • find_symbol_definitions Tauri command with parallel file processing

TypeScript API (4 modified files)

  • SymbolDefinition type, findSymbolDefinitions() in ApiClient interface + TauriClient + HttpClient stub

React hooks (2 new files)

  • useCmdKeyHeld — tracks Meta key state via keydown/keyup/blur
  • useGoToDefinition — full flow: word extraction via composedPath(), keyword filtering, backend lookup, navigation or picker

UI (5 modified files, 1 new file)

  • DefinitionPicker — Radix Dialog with keyboard navigation (arrows, Enter, Esc)
  • onLineClick wired into DiffView and PlainCodeView options
  • Props threaded through FileContentRenderer and CodeViewer index

Test plan

  • Run scripts/test — TypeScript type check + Rust tests pass
  • Hold Cmd and hover over a symbol — cursor changes to pointer, text underlines
  • Cmd+Click a function/class name — navigates to definition file and scrolls to line
  • Cmd+Click a symbol with multiple definitions — picker dialog appears
  • Cmd+Click a keyword (if, return, etc.) — no-op
  • Regular click (no Cmd) — existing behavior unchanged

The minimap now attaches its own passive scroll listener and
ResizeObserver on the scrollContainer prop, directly mutating
its viewport indicator div. This removes the forwardRef/
useImperativeHandle plumbing and the useScrollPosition hook
from CodeViewer, simplifying parent↔minimap communication.
Cmd+Click on a symbol in the diff/file viewer navigates to its
definition. Uses git grep to narrow candidate files, then tree-sitter
symbol extraction to find exact matches. Single result navigates
directly; multiple results show a picker dialog.

- Rust: new find_symbol_definitions Tauri command with parallel
  tree-sitter processing
- TypeScript: SymbolDefinition type, API client method
- React: useCmdKeyHeld and useGoToDefinition hooks
- UI: DefinitionPicker dialog, Cmd+hover cursor/underline styling
  via onLineClick in @pierre/diffs
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