mirror of
https://github.com/zed-industries/zed.git
synced 2026-11-24 01:20:29 +01:00
0bdc70c2eb
## Summary Cmd-clicking a symbol whose name matches its own file did nothing at all — no navigation, no references list, no toast. When Zed sees a word that might be a file path, it tries appending the language's file extensions before giving up, so the word `TestClass` matches a file named `TestClass.php`. A symbol named after the file it lives in therefore produces two hover links: a definition pointing at the cursor itself, and a file link pointing at the buffer already open. The definition was correctly dropped as a self-link, but the file link survived. Cmd-click then "navigated" by re-opening the current file and returned `Navigated::Yes`, which suppressed the go-to-definition fallback — so `textDocument/references` was never sent and the click silently did nothing. This applies the same self-link rule to file links: drop one that resolves to the buffer we are already in, and leave every other file link alone so cmd-clicking a path in a comment still opens it. Closes #64063 ## Testing Two tests, one for each half of the rule: - `test_cmd_click_on_file_link_to_current_file_falls_back_to_references` — fails if the fix is reverted - `test_cmd_click_on_file_link_to_another_file_still_navigates` — fails if the fix is narrowed to dropping all file links, which resolves the bug but breaks cmd-click on ordinary paths in comments Verified both go red with the fix reverted. Manually verified on macOS with the PHP reproduction from the issue: cmd-clicking `TestClass` in `TestClass.php` now opens the references list, and cmd-clicking a file path in a comment still opens that file. ## Self-review - [x] I've reviewed my diff for quality, security, reliability, and performance. - [ ] UI changes follow the [checklist](https://zed.dev/docs/development/ui-checklist). — no UI changes - [x] Tests cover the new or changed behavior. Release Notes: - Fixed cmd-click doing nothing on a symbol whose name matches its file name https://github.com/user-attachments/assets/72550d00-f668-4727-bdde-1456f0b50e66