Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

keymaps: Fix how single line editor handles new lines in BufferSearch #19316

Merged
merged 1 commit into from
Nov 5, 2024

Conversation

narqo
Copy link
Contributor

@narqo narqo commented Oct 16, 2024

This PR updates the JetBrains keymaps preset to handle the shift-enter combination as the SelectPrevMatch action.

That is, it seems that, with the current defaults, pressing the Shift+Enter inside the search editor (single_line mode Editor inside the BufferSearchBar) triggers the "Editor::newline". With the updated defaults, it works as I expect it.

Also, the PR adds the alt-enter in the context of the editor inside the BufferSearchBar to trigger the newline. This matches with how it works in other editors on macOS, e.g. in Xcode.

Release Notes:

  • N/A

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Oct 16, 2024
@notpeter
Copy link
Member

notpeter commented Oct 17, 2024

Hi @narqo,

These changes are not correct:

{
"context": "BufferSearchBar > Editor",
"bindings": {
"alt-enter": "editor::Newline",
"shift-enter": "search::SelectPrevMatch"
}
},

  1. Your changes break the existing alt-enter mapping in the BufferSearchBar context: (multi-select all matches)

    "alt-enter": "search::SelectAllMatches",

  2. Were we to add it to this context, the key would be ctrl-enter (like vscode) not alt-enter (like XCode), but we'd likely want fix this before shipping a new default keybinding:

  1. The thing you are trying to fix, shift-enter being broken -- is only broken in vim mode. It already works fine by default in non-vim mode.

@narqo narqo force-pushed the keymaps-macos-buffer-search branch from 709581b to 5410d14 Compare October 17, 2024 18:53
@narqo
Copy link
Contributor Author

narqo commented Oct 17, 2024

@notpeter, you're right, my bad. I missed that part that I'm using JetBrains preset, where the shift-enter combination is used for the new line, and clashes with search::SelectPrevMatch. I've updated the PR (and the description), moving the fix to the corresponding [jetbrains] preset. PTAL.

@notpeter
Copy link
Member

notpeter commented Oct 17, 2024

I was able to actually reproduce this with the default vscode keymap + vim mode and so I think the underlying issue might be one with Vim mode contexts. That is, shift-enter correctly works in this context when vim mode is off, but is broken when vim mode is on:

"context": "BufferSearchBar",
"bindings": {
"escape": "buffer_search::Dismiss",
"tab": "buffer_search::FocusEditor",
"enter": "search::SelectNextMatch",
"shift-enter": "search::SelectPrevMatch",

It's probably worth filing an issue as changing the keymap is not likely the correct solution.

@narqo
Copy link
Contributor Author

narqo commented Oct 17, 2024

I think the underlying issue might be one with Vim mode contexts

I don't use Vim mode, but I use the JetBrains base keymap. Sorry for the confusion. You can look up my full set of Zed settings in this gist, if that helps.

@notpeter notpeter merged commit d6fcd98 into zed-industries:main Nov 5, 2024
13 checks passed
@notpeter
Copy link
Member

notpeter commented Nov 5, 2024

Thanks!

@narqo narqo deleted the keymaps-macos-buffer-search branch November 5, 2024 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed The user has signed the Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants