zed/crates/editor
Ozan 72d8f2e595
editor: Add "selection" key context (#21927)
This change allows defining keybindings that are active when there is a
text selection.

This is especially useful, as an example, for Emacs-like keybindings
where movement keybindings expand the selection.

Here is a snippet from my keymap.json that implements Emacs movements
when selection is active:

```json
{
    "context": "Editor && selection",
    "bindings": {
      "ctrl-f": "editor::SelectRight",
      "ctrl-b": "editor::SelectLeft",
      "ctrl-n": "editor::SelectDown",
      "ctrl-p": "editor::SelectUp",
      "ctrl-a": "editor::SelectToBeginningOfLine",
      "ctrl-e": "editor::SelectToEndOfLine",
      "alt-f": "editor::SelectToNextWordEnd",
      "alt-b": "editor::SelectToPreviousWordStart",
      "alt-<": "editor::SelectToBeginning",
      "alt->": "editor::SelectToEnd"
    }
  }
  ```

What do you think about inclusion of this feature? Should I add more granular `selection=single` `selection=multi`? 

Release Notes:

- Added "selection" context for keybindings that are active when there is a text selection.
2024-12-12 16:56:42 -08:00
..
src editor: Add "selection" key context (#21927) 2024-12-12 16:56:42 -08:00
Cargo.toml editor: Add actions for inserting UUIDs (#21656) 2024-12-06 14:32:09 -05:00
LICENSE-GPL chore: Change AGPL-licensed crates to GPL (except for collab) (#4231) 2024-01-24 00:26:58 +01:00