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
46.03k stars 2.57k forks source link

Toggle Replace `cmd-alt-f` key binding not working on macOS #12583

Open gabrielkoerich opened 3 months ago

gabrielkoerich commented 3 months ago

Check for existing issues

Describe the bug / provide steps to reproduce it

I'm using Zed with vim_mode=true and custom key bindings for search/replace. I added "alt-cmd-f": "search::ToggleReplace" in some contexts and it shows on the editor that this should be the correct key binding for toggling replace: Screenshot 2024-06-02 at 10 53 21

But I can't make it work, I always have to do first a cmd-f to search and then toggle the replace manually. First I was using the SublimeText base keymap, but I remove it and added just some custom key bindings. Am I doing something wrong here? Thanks!

Environment

Zed: v0.137.6 (Zed) OS: macOS 14.5.0 Memory: 32 GiB Architecture: aarch64

My current key bindings:

[
  {
    "bindings": {
      "cmd-shift-[": "pane::ActivatePrevItem",
      "cmd-shift-]": "pane::ActivateNextItem",
      "ctrl-pagedown": "pane::ActivatePrevItem",
      "ctrl-pageup": "pane::ActivateNextItem",
      "ctrl-shift-tab": "pane::ActivateNextItem",
      "ctrl-tab": "pane::ActivatePrevItem",
      "cmd-+": "zed::IncreaseBufferFontSize",
      // "ctrl-c left": ["workspace::ActivatePaneInDirection", "Left"],
      "ctrl-a |": "pane::SplitRight",
      "ctrl-a _": "pane::SplitDown"
    }
  },
  {
    "context": "ProjectSearchBar",
    "bindings": {
      "escape": "project_search::ToggleFocus",
      "cmd-f": "search::FocusSearch",
      "cmd-alt-f": "search::ToggleReplace"
    }
  },
  {
    "context": "ProjectSearchView",
    "bindings": {
      "escape": "project_search::ToggleFocus",
      "cmd-alt-f": "search::ToggleReplace"
    }
  },
  {
    "context": "Pane",
    "bindings": {
      "f4": "search::SelectNextMatch",
      "shift-f4": "search::SelectPrevMatch",
      "cmd-alt-f": "search::ToggleReplace",
      "alt-cmd-f": "search::ToggleReplace"
    }
  },
  {
    "context": "Editor",
    "bindings": {
      "ctrl-shift-up": "editor::AddSelectionAbove",
      "ctrl-shift-down": "editor::AddSelectionBelow",
      "cmd-shift-space": "editor::SelectAll",
      "ctrl-shift-m": "editor::SelectLargerSyntaxNode",
      "cmd-shift-l": "editor::SplitSelectionIntoLines",
      "cmd-shift-a": "editor::SelectLargerSyntaxNode",
      "shift-f12": "editor::FindAllReferences",
      "alt-cmd-down": "editor::GoToDefinition",
      "ctrl-alt-cmd-down": "editor::GoToDefinitionSplit",
      "alt-shift-cmd-down": "editor::FindAllReferences",
      "ctrl-.": "editor::GoToHunk",
      "ctrl-,": "editor::GoToPrevHunk",
      "ctrl-backspace": "editor::DeleteToPreviousWordStart",
      "ctrl-delete": "editor::DeleteToNextWordEnd"
    }
  },
  {
    "context": "Editor && mode == full",
    "bindings": {
      "cmd-r": "outline::Toggle"
    }
  },
  {
    "context": "Workspace",
    "bindings": {
      "cmd-k cmd-b": "workspace::ToggleLeftDock",
      "cmd-t": "file_finder::Toggle",
      "cmd-r": "outline::Toggle",
      // "shift-cmd-r": "project_symbols::Toggle",
      // Currently busted: https://github.com/zed-industries/feedback/issues/898
      "ctrl-0": "project_panel::ToggleFocus",
      "cmd-shift-r": "workspace::ToggleRightDock",
      "cmd-f": "pane::DeploySearch",
      "cmd-alt-f": [
        "pane::DeploySearch",
        {
          "replace_enabled": true
        }
      ]
    }
  }
]

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.

No response

gabrielkoerich commented 3 months ago

If I remove "cmd-alt-f": "search::ToggleReplace" on Pane context, the key binding is back to the default cmd-shift-h which works when pressing it. But cmd-alt-f doesn't work, maybe some kind of conflict?

I can't also remap cmd-r, it always toggles the right dock anyway. Maybe related to #12555?

JosephTLyons commented 2 months ago

These seem like bugs - I'm experiencing the same issues on my end.

notpeter commented 1 month ago

@gabrielkoerich I wonder whether it's because we actually a different modifier key order for our Pane context one:

  { 
    "context": "Editor && mode == full",
    "bindings": {
      "cmd-alt-f": ["buffer_search::Deploy", { "replace_enabled": true }]
    }
  },{
    "context": "BufferSearchBar",
    "bindings": {
      "cmd-alt-f": "search::ToggleReplace"
    }
  },{
    "context": "Pane",
    "bindings": {
      "alt-cmd-f": "project_search::ToggleFilters"
    }
  }

Can you see if changing your Pane definition in your keymap.json fixes it?

- "cmd-alt-f": "search::ToggleReplace",
+ "alt-cmd-f": "search::ToggleReplace",
notpeter commented 1 month ago

Bump @gabrielkoerich.

Curious whether you're still running into this and whether the work around I suggested had any impact.

gabrielkoerich commented 3 weeks ago

@notpeter I doesn't work either 😕 I had already tried this, if you look my keymaps I have both: cmd-alt-f and alt-cmd-f. Tried again with just one of them but no success. This search/replace is still annoying to do only using the keyboard, I guess I need to learn to just do it using vim mode