Skip to content

Conversation

@riandrake
Copy link
Contributor

@riandrake riandrake commented Oct 7, 2025

NewFileSplitHorizontal and NewFileSplitVertical don't allow me to create new file splits in all 4 directions, so I've created 4 new actions that allow new splits to Left, Down, Up, and Right directions.

Haven't changed the behaviour of the existing actions because the direction of horizontal and vertical is user-configured.

This PR is for people like me who want to be able to create splits in 4 directions at will, I usually bind like so:

{
    "context": "Editor",
    "bindings": {
      "ctrl-s ctrl-h": ["workspace::NewFileSplit", "left"],
      "ctrl-s ctrl-j": ["workspace::NewFileSplit", "down"],
      "ctrl-s ctrl-k": ["workspace::NewFileSplit", "up"],
      "ctrl-s ctrl-l": ["workspace::NewFileSplit", "right"]
    }
  }

Release Notes:

  • Added workspace::NewFileSplit action, which can be used to programmatically split the editor in the provided direction.

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Oct 7, 2025
@ConradIrwin ConradIrwin assigned dinocosta and unassigned ConradIrwin Oct 14, 2025
@dinocosta
Copy link
Contributor

Hey @riandrake ! Thank you for the PR and for trying to improve Zed 🙂

I like the idea of letting users create splits in all directions, and your changes worked well in my testing. That said, the NewFileSplit[Left/Down/Up/Right] naming feels a bit too specific and adds a lot of commands to the palette. Since we already have workspace::pane_group::SplitDirection, we can lean on that.

What I propose is a single action: NewFileSplit(pub SplitDirection). That would let us map directions via bindings like:

{
  "context": "Editor",
  "bindings": {
    "ctrl-s ctrl-h": ["workspace::NewFileSplit", "left"],
    "ctrl-s ctrl-j": ["workspace::NewFileSplit", "down"],
    "ctrl-s ctrl-k": ["workspace::NewFileSplit", "up"],
    "ctrl-s ctrl-l": ["workspace::NewFileSplit", "right"]
  }
}

This avoids four separate methods (new_file_left, new_file_down, new_file_up, new_file_right) and replaces them with a single new_file_split that passes SplitDirection to Editor::new_file_in_direction.

Happy to have you take a swing at it, pair on it, or I can handle it, whatever’s easiest ✌️

@riandrake
Copy link
Contributor Author

Hi @dinocosta , thanks for the feedback! I'm not very familiar with Rust, but I gave it a shot and got something going.

I wasn't able to get it working with just a string argument in the json as you drafted (instead it's { "direction": "left" }), but if you can point me to an example I can try again.

@dinocosta
Copy link
Contributor

@riandrake Thanks for taking another look at this. Your updated code looks good to me 🙌

If you’re still up for it, here’s some additional feedback you might incorporate:

  • You can get it working with just the string argument if you define the action’s struct as a tuple struct, see struct – Rust. For example, take a look at the FoldAtLevel action.
  • On naming, NewFileSplit might make more sense, since we already use NewFileSplitHorizontal and NewFileSplitVertical.

Feel free to implement this feedback, otherwise, I believe this is ready to merge as is 🙂

@riandrake
Copy link
Contributor Author

@dinocosta done!

@dinocosta
Copy link
Contributor

@dinocosta done!

Awesome! Thank you so much for tackling all the suggested changes and seeing this through! I've updated the PR Description's with the release notes and will now merge this 🎉

@dinocosta dinocosta changed the title Expand NewFile actions with discrete directions (Left, Down, Up, Right) workspace: Add NewFileSplit action with direction Oct 20, 2025
@dinocosta dinocosta merged commit 8bef480 into zed-industries:main Oct 20, 2025
38 of 40 checks passed
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.

4 participants