Add ctrl-w _ and ctrl-w = (#21227)

Closes #ISSUE

Release Notes:

- vim: Add support for `ctrl-w _` and `ctrl-w =`
This commit is contained in:
Conrad Irwin 2024-11-26 16:45:38 -08:00 committed by GitHub
parent f702575255
commit 4e720be41c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 55 additions and 4 deletions

View file

@ -41,7 +41,7 @@ use state::{Mode, Operator, RecordedSelection, SearchState, VimGlobals};
use std::{mem, ops::Range, sync::Arc};
use surrounds::SurroundsType;
use theme::ThemeSettings;
use ui::{IntoElement, VisualContext};
use ui::{px, IntoElement, VisualContext};
use vim_mode_setting::VimModeSetting;
use workspace::{self, Pane, ResizeIntent, Workspace};
@ -79,7 +79,9 @@ actions!(
InnerObject,
FindForward,
FindBackward,
OpenDefaultKeymap
OpenDefaultKeymap,
MaximizePane,
ResetPaneSizes,
]
);
@ -117,8 +119,29 @@ pub fn init(cx: &mut AppContext) {
});
});
workspace.register_action(|workspace, _: &ResetPaneSizes, cx| {
workspace.reset_pane_sizes(cx);
});
workspace.register_action(|workspace, _: &MaximizePane, cx| {
let pane = workspace.active_pane();
let Some(size) = workspace.bounding_box_for_pane(&pane) else {
return;
};
let theme = ThemeSettings::get_global(cx);
let height = theme.buffer_font_size(cx) * theme.buffer_line_height.value();
let desired_size = if let Some(count) = Vim::take_count(cx) {
height * count
} else {
px(10000.)
};
workspace.resize_pane(Axis::Vertical, desired_size - size.size.height, cx)
});
workspace.register_action(|workspace, action: &ResizePane, cx| {
let count = Vim::take_count(cx.window_context()).unwrap_or(1) as f32;
let count = Vim::take_count(cx).unwrap_or(1) as f32;
let theme = ThemeSettings::get_global(cx);
let Ok(font_id) = cx.text_system().font_id(&theme.buffer_font) else {
return;