Improve link pattern parsing to trim punctuation wrappers#45457
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Pull request overview
This pull request improves jump-to-definition reliability for file paths embedded in prose text (comments, markdown, documentation) by implementing smarter punctuation stripping. The changes enable cmd/ctrl-click navigation on file paths wrapped in common punctuation patterns like markdown backticks, parentheses, brackets, and sentence-ending punctuation.
Key Changes:
- Enhanced
link_pattern_file_candidatesto iteratively strip leading and trailing punctuation characters from file path candidates - Introduced ordered candidate generation (trimmed → regex-extracted → raw) with deduplication
- Refactored
test_hover_filenamesto use a DRY approach with a base document and targeted line replacements
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
207b9bb to
d026e11
Compare
Handles markdown and prose patterns like [title](path), `path`, (path), and partial wrappers. Returns candidate file paths ordered from most- specific (trimmed) to least-specific (raw). Expands and updates tests for various edge cases.
d026e11 to
921a08d
Compare
|
sorry for the delay. Once the merge conflicts are resolved I'd be happy to merge this |
…kdown-jump-to-def-improved-candidates
…thub.com/subtleGradient/zed into markdown-jump-to-def-improved-candidates
…ries#45457) Closes # (none) ## Summary Improved the jump-to-definition reliability for file paths in prose strings (comments, markdown, etc.) by smarter stripping of surrounding punctuation. This allows `cmd/ctrl-click` to work on file paths in contexts like: - **Markdown backticks**: `` `path/to/file` `` - **Markdown links**: `[link](path/to/file)` - **Parentheses**: `(see path/to/file)` - **Sentence endings**: `Check path/to/file.` - **Code spans**: `` `cat path/to/file` `` ## Technical Details - Updated `link_pattern_file_candidates` in `hover_links.rs` to iteratively trim common leading and trailing punctuation characters. - Candidate generation now produces multiple variations (trimmed, regex match, raw) ordered by specificity (most trimmed first). - Refactored `test_hover_filenames` to be DRY: it now uses a single base document string and targeted replacements, making it easier to add new prose test cases without duplication. Release Notes: - Improved jump-to-definition reliability for file paths wrapped in punctuation (backticks, parens, sentence endings). --------- Co-authored-by: Martin Ye <martin@zed.dev> Co-authored-by: MartinYe1234 <52641447+MartinYe1234@users.noreply.github.com>

Closes # (none)
Summary
Improved the jump-to-definition reliability for file paths in prose strings (comments, markdown, etc.) by smarter stripping of surrounding punctuation.
This allows
cmd/ctrl-clickto work on file paths in contexts like:`path/to/file`[link](path/to/file)(see path/to/file)Check path/to/file.`cat path/to/file`Technical Details
link_pattern_file_candidatesinhover_links.rsto iteratively trim common leading and trailing punctuation characters.test_hover_filenamesto be DRY: it now uses a single base document string and targeted replacements, making it easier to add new prose test cases without duplication.Release Notes: