vim: Add keybindings for resizing docks (#23874)

Closes #23334

This does not follow the exact way that windows are resized in vim.
Normally the command is `ctrl-w >` however this PR uses just `ctrl->`.
This is because I could not find a good way to read in a count like `10
ctrl-w ctrl->`. This is not really a problem since `ctrl->` can be held
down, which, in my opinion, speeds up resizing. I think this is a good
compromise since it improves usability; however, I am concerned that
this is not intuitive. I am looking forward to feedback.

Release Notes:

- Added the following commands 
  - vim::ResizeLeftDock
  - vim::ResizeRightDock
  - vim::ResizeBottomDock
- Added keybinds
  - `ctrl->` for widening left dock
  - `ctrl-<` for narrowing left dock
This commit is contained in:
AidanV 2025-01-31 20:50:16 -08:00 committed by GitHub
parent a3c7dc3321
commit d0152f9eb4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 28 additions and 6 deletions

View file

@ -3240,9 +3240,31 @@ impl Workspace {
}
}
pub fn resize_pane(&mut self, axis: gpui::Axis, amount: Pixels, cx: &mut Context<Self>) {
self.center
.resize(&self.active_pane, axis, amount, &self.bounds);
pub fn resize_pane(
&mut self,
axis: gpui::Axis,
amount: Pixels,
window: &mut Window,
cx: &mut Context<Self>,
) {
let docks = self.all_docks();
let active_dock = docks
.into_iter()
.find(|dock| dock.focus_handle(cx).contains_focused(window, cx));
if let Some(dock) = active_dock {
let Some(panel_size) = dock.read(cx).active_panel_size(window, cx) else {
return;
};
match dock.read(cx).position() {
DockPosition::Left => resize_left_dock(panel_size + amount, self, window, cx),
DockPosition::Bottom => resize_bottom_dock(panel_size + amount, self, window, cx),
DockPosition::Right => resize_right_dock(panel_size + amount, self, window, cx),
}
} else {
self.center
.resize(&self.active_pane, axis, amount, &self.bounds);
}
cx.notify();
}