zed icon indicating copy to clipboard operation
zed copied to clipboard

`cmd+click` symbol definition to find all references does not work in vim mode

Open Congyuwang opened this issue 1 year ago • 5 comments

Check for existing issues

  • [X] Completed

Describe the bug / provide steps to reproduce it

When "vim_mode": true, cmd + click only GoToDefinition but does not FindAllReference when clicking on def (in INSERT or NORMAL mode).

If vim mode is disabled, however, the bidirectional cmd + click works properly.

https://github.com/zed-industries/zed/assets/52687642/22a71a2c-eb77-4804-a1ec-254e05e176fc

__

Environment

Zed: v0.131.1 (Zed Preview) OS: macOS 14.4.1 Memory: 16 GiB Architecture: aarch64

If applicable, add mockups / screenshots to help explain present your vision of the feature

Bidirectional cmd + click should work also in vim mode. Related #9259 .

If applicable, attach your ~/Library/Logs/Zed/Zed.log file to this issue.

No response

Congyuwang avatar Apr 11 '24 01:04 Congyuwang

I wonder whether this is reproducible by others?

Congyuwang avatar Apr 14 '24 05:04 Congyuwang

Yeah, I can reproduce it.

mrnugget avatar Apr 15 '24 13:04 mrnugget

I investigated the code. The current implementation: after cmd+clicking, if definition is found, check whether the selected definition range covers where the cursor previously was before the definition is revealed (if definition is not revealed elsewhere, it is revealed right here, so I am clicking right on the definition, so let's do FindAllReference).

https://github.com/zed-industries/zed/blob/c81eb419d44ec141956f6132c2f61723641c490d/crates/editor/src/hover_links.rs#L215-L253

This is working fine when vim mode is false. However, when vim mode is enabled, let selection_after_revealing = editor.selections.newest::<Point>(cx); does not select the whole definition range, but only the first character of the definition, which does not overlap with the old cursor position, and so revealed_elsewhere = ! before_intersects_after_range is now true, and FindAllReference is not performed.

Congyuwang avatar Apr 17 '24 05:04 Congyuwang

Should vim go to VISUAL mode when jumping to definition?

Congyuwang avatar Apr 17 '24 06:04 Congyuwang

Should vim go to VISUAL mode when jumping to definition?

Hmmm, I'm not sure but that sounds wrong. I wonder whether we could change the check to say that if vim mode { if current_cursor already within the range of the definition } or something like that.

mrnugget avatar Apr 17 '24 07:04 mrnugget