# editor: Fix cmd-click doing nothing on a symbol named after its file \(\#64892\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/0bdc70c2ebfb3f75c597f04f3e9540f992c86626)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 0bdc70c2ebfb3f75c597f04f3e9540f992c86626

Requested commit: 0bdc70c2ebfb3f75c597f04f3e9540f992c86626

Commit: 0bdc70c2ebfb3f75c597f04f3e9540f992c86626

Tree: 544eaddff3626e757de0dcf1ae798f812f0daf47

Author: Manoj sk

Committer: GitHub

## Message

```
editor: Fix cmd-click doing nothing on a symbol named after its file (#64892)

## 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
```

## Parents

- [66432e4ca957383dcc9ec61d1353a4b4bd94c6bc](https://git.cafe/gitcafe/zed/commit/66432e4ca957383dcc9ec61d1353a4b4bd94c6bc?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/0bdc70c2ebfb3f75c597f04f3e9540f992c86626?format=markdown)
