zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
49.82k stars 3.06k forks source link

[vim]: If search is opened with cmd-f, enter should act like non-vim mode #7692

Open shinebayar-g opened 9 months ago

shinebayar-g commented 9 months ago

Check for existing issues

Describe the bug / provide steps to reproduce it

When searching for text, search window should loop through the results when ENTER key is pressed and shouldn't do anything except maybe beep sound for no result.

Currently when I press ENTER key it edits the code and adds new line.

image

Environment

Zed: v0.122.2 (Zed Preview) OS: macOS 14.3.1 Memory: 16 GiB Architecture: aarch64

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

No response

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

If you only need the most recent lines, you can run the zed: open log command palette action to see the last 1000.

No response

mrnugget commented 9 months ago

Hey @shinebayar-g! I cannot reproduce this. When I search in the buffer and the search input is focused, enter gets me to the next search result.

See here: https://github.com/zed-industries/zed/assets/1185253/ec3eb75e-0464-43bd-b52f-03f4b6b330ca

Or do you use Vim mode by any chance?

d1y commented 9 months ago

Or do you use Vim mode by any chance?

The enable vim-mode same will enter new lines

demo

shinebayar-g commented 9 months ago

Or do you use Vim mode by any chance?

Hey @mrnugget , thanks for the hint. I noticed that It's only reproducible in Vim mode.

mrnugget commented 9 months ago

Okay, I see. But where does this expectation come from? As far as I know (and I just checked again): by default Vim doesn't bind <enter> to go-to-next-search-result. It's bound to n and <cr> is equivalent to ctrl-m.

shinebayar-g commented 9 months ago

yeah 😞

d1y commented 9 months ago

Okay, I see. But where does this expectation come from? As far as I know (and I just checked again): by default Vim doesn't bind <enter> to go-to-next-search-result. It's bound to n and <cr> is equivalent to ctrl-m.

And. The shift-enter useful in vim-mode (prev-result)? If so, it would be more intuitive to bind enter to the search input(box)

mrnugget commented 9 months ago

I still can't reproduce this. When I search in Vim mode with / and then hit <enter> I only jump the next line, just like in Vim.

https://github.com/zed-industries/zed/assets/1185253/b30ef37c-70ac-485a-a7a5-32353dc01dfd

shinebayar-g commented 9 months ago

I still can't reproduce this. When I search in Vim mode with / and then hit <enter> I only jump the next line, just like in Vim. screenshot-2024-02-13-16.49.37.mp4

You beat me to it 😄 . Try the same when you're in INSERT mode.

d1y commented 9 months ago

I still can't reproduce this. When I search in Vim mode with / and then hit <enter> I only jump the next line, just like in Vim.

screenshot-2024-02-13-16.49.37.mp4

Disable all my custom keymap and use "/" + "cmd+shift+f" <enter> not work

vim-mode "n" / "shift-n" prev/next result it work

sb.gif

mrnugget commented 9 months ago

Okay, so you want to work like in non-vim-mode when you trigger a search through cmd+f/cmd-shift-f even though you're in Vim mode, yes?

shinebayar-g commented 9 months ago

Yeah I would be glad if certain base functionalities work the same across vim/non-vim modes.. Like search.

d1y commented 9 months ago

I think that when the search-input is focused, triggering enter should trigger an operation (such as next-result), rather than unfocus and jump to the result. This is not in line with the habits we have developed using other applications.

mrnugget commented 9 months ago

I think that when the search-input is focused, triggering enter should trigger an operation (such as next-result), rather than unfocus and jump to the result. This is not in line with the habits we have developed using other applications.

I personally prefer that, because it's exactly how it works in Vim: you start a search with /, you finish it by hitting enter, you jump to the next search results with n/N. That's at least the habit I've developed over a decade of using Vim :)

But I think the solution here would be to change the behaviour depending on whether the search was started via cmd-f or via /.

d1y commented 9 months ago

I'm just wondering why 'shift enter' works. Is this bug?

fix

The default bind

image
shinebayar-g commented 9 months ago

This is what I wanted to say. There is a difference between searching in NORMAL vs INSERT mode. NORMAL mode works as expected. return key jumps to the next result. In INSERT mode it doesn't. It inserts new line instead.

https://github.com/zed-industries/zed/assets/3091558/efba782a-5c60-416d-bd18-ce063181beb3

github-actions[bot] commented 1 month ago

Hi there! 👋 We're working to clean up our issue tracker by closing older issues that might not be relevant anymore. Are you able to reproduce this issue in the latest version of Zed? If so, please let us know by commenting on this issue and we will keep it open; otherwise, we'll close it in a week. Feel free to open a new issue if you're seeing this message after the issue has been closed. Thanks for your help!

viveksjain commented 1 month ago

Still an issue

shinebayar-g commented 2 days ago

Can this issue be re-evaluated? Without enter working, ctrl+f is kind of useless. Whenever I press enter it just moves cursor to the next line instead of jumping to the next match.

Clicking n to navigate to the next match works only if the find bar is not in focus. If the find bar is still in focus it adds n to the search input. So UX around is not so great.