zed
zed copied to clipboard
Double-click in multi-buffer to jump to that location in a single-buffer
Check for existing issues
- [X] Completed
Is your feature request related to a problem?
While using Zed as the only editor for a whole day, I was constantly trying to double-click into a multi-buffer to open that location in a single-buffer, but this doesn't work.
I know that Zed has little arrows to jump to locations, but I personally found them to be hard to locate and hard to mentally assign them to their corresponding code locations (as they are always quite far off to the up and right of the code location they correspond to):
Describe the solution you'd like
In both Sublime Text and VSCode, you can double-click the occurrence in a search result to open it in a single-buffer.
In Sublime Text, it only works for double clicks on the highlighted occurrence. Double-clicks everywhere else in the excerpt fall back to the default double-click behaviour. In VSCode it works for double-clicks everywhere in the excerpt and it moves the cursor in the single-buffer to the location you've double-clicked.
I'd personally prefer the behaviour of VSCode as I sometimes want to directly jump to an adjacent line. I'd also like this to work in all multi-buffers, e.g. in the find all references one.
If applicable, add mockups / screenshots to help present your vision of the feature
Example from Sublime Text:
https://user-images.githubusercontent.com/409021/180222442-d252d853-9add-4d4c-85b5-bb891761bfe8.mov
Any thoughts on what to do with the "select word" behavior in this case? I guess triple click could be select word and quadruple click could be select line. Or maybe we just don't offer word selection.
@rkusa Thanks for the report. I also worry about the inconsistency with double click's behavior in a regular editor. Curious about your thoughts on an alternative solution - What if we added a context menu item for Jump to Buffer
when right clicking on a multi-buffer? I'm wondering if that would improve the experience for you.
@nathansobo @maxbrunsfeld Good question! I haven't really through about this before as I rarely select words with double-clicks. But I can totally see that others use it and I agree that having consistent behaviors between single- and multi-buffers would be great.
I found out that this behavior can be adjusted in VSCode:
A setting to adjust the behavior could be a solution, but maybe we can come up with something else that is both convenient to use, consistent and doesn't require a setting.
What if we added a context menu item for
Jump to Buffer
when right clicking on a multi-buffer? I'm wondering if that would improve the experience for you.
I'd consider this an improvement over the current arrow (at least in its current location). To emphasize, this is where those arrows are in location to the code on a widescreen without splits (to be fair, fullscreen on a widescreen without splits probably only happens shortly at the beginning of the day).
While I think it is a good idea to have it in the right click menu, I don't find it convenient enough as it still requires a right click, visually locating the entry, navigating the mouse to it and clicking it.
While responding, I saw that the arrows actually have a shortcut: alt-enter
(editor::OpenExcerpts
). This discovery makes it already way more usable IMO. But if allowed to nitpick, it still requires to switch form navigating around with the mouse to the keyboard.
Would something like alt-doubleClick
or cmd-doubleClick
feasible (latter probably conflicts with cmd-click
which currently triggers on the first mouse down)?
I like the alt-double-click (or alt-click) idea.
Adding my vote here. Super frustrating and I definitely thought this was a bug. When there are multiple locations that have a search results, it's really unclear on how to get to one of them. Is it even possible right now?
<modifier>+click
would work but not as discoverable.
For prioritization: Can say this was my immediate and first frustrating experience with Zed. There's no education alt-enter, and I don't even see the arrow mentioned in some old screenshots.
This is supposed to be shipped in Zed 0.127.0
Hey, I would expect that for the default setting "select", alt + double click would open in a new buffer. Wouldn't that make sense?
Frankly speaking, the whole "double click to navigate" multibuffer feature does not make any sense to me with the alt-enter binding present; now I also regret touching this issue at all as it had caused some controversy around.
This is the code responsible for everything related:
https://github.com/zed-industries/zed/blob/65152baa3f7a55b7a57030d7eef1f94640bb9afa/crates/editor/src/element.rs#L419-L471
there seems to be some logic related to alt
+ single clicks that places another caret in the [multi]buffer if the settings are right, but that does not seem very related to this issue, so the // do nothing special on double click, all selection logic is below
part could be replaced with more logic to handle this case.
Does not seem like a wrong thing to do, but I won't be the one pushing more changes on top of all this — yet ready to review some, if tagged in the PR.