first pass of merging in warp (doesn't build)
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
use galaxyui::keymap::{EditableBinding, Keystroke, Trigger};
|
||||
use galaxyui::platform::OperatingSystem;
|
||||
use galaxyui::{
|
||||
keymap::{EditableBinding, Keystroke, Trigger},
|
||||
App,
|
||||
};
|
||||
use galaxyui::App;
|
||||
|
||||
use crate::{util::bindings::keybinding_name_to_display_string, workspace::WorkspaceAction};
|
||||
use crate::terminal;
|
||||
use crate::util::bindings::{keybinding_name_to_display_string, trigger_to_keystroke};
|
||||
use crate::workspace::WorkspaceAction;
|
||||
|
||||
#[test]
|
||||
fn test_keybinding_name_to_display_string() {
|
||||
@@ -72,3 +72,91 @@ fn test_keybinding_name_to_display_string() {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_orchestration_cycle_bindings_are_editable() {
|
||||
App::test((), |mut app| async move {
|
||||
app.update(terminal::init);
|
||||
|
||||
app.update(|ctx| {
|
||||
let next = ctx
|
||||
.editable_bindings()
|
||||
.find(|binding| binding.name == "terminal:cycle_next_orchestration_child_agent")
|
||||
.and_then(|binding| trigger_to_keystroke(binding.trigger));
|
||||
let previous = ctx
|
||||
.editable_bindings()
|
||||
.find(|binding| binding.name == "terminal:cycle_previous_orchestration_child_agent")
|
||||
.and_then(|binding| trigger_to_keystroke(binding.trigger));
|
||||
|
||||
assert_eq!(next, Keystroke::parse("ctrl-alt-]").ok());
|
||||
assert_eq!(previous, Keystroke::parse("ctrl-alt-[").ok());
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_toggle_maximize_pane_binding_is_editable() {
|
||||
App::test((), |mut app| async move {
|
||||
app.update(crate::pane_group::init);
|
||||
|
||||
app.update(|ctx| {
|
||||
use crate::pane_group::TOGGLE_MAXIMIZE_PANE_BINDING_NAME;
|
||||
|
||||
// The toggle-maximize-pane action is registered as an editable binding so
|
||||
// it can be assigned a shortcut in Settings → Keyboard shortcuts.
|
||||
assert!(
|
||||
ctx.editable_bindings()
|
||||
.any(|binding| binding.name == TOGGLE_MAXIMIZE_PANE_BINDING_NAME),
|
||||
"{TOGGLE_MAXIMIZE_PANE_BINDING_NAME} should be registered as an editable binding"
|
||||
);
|
||||
|
||||
// It ships with a mac-only default shortcut (cmd-shift-enter) via its custom
|
||||
// action; other platforms have no default until the user assigns one. Either
|
||||
// way, whatever resolves here is what the pane header menu item surfaces.
|
||||
let default = keybinding_name_to_display_string(TOGGLE_MAXIMIZE_PANE_BINDING_NAME, ctx);
|
||||
if OperatingSystem::get().is_mac() {
|
||||
assert_eq!(Some("⇧⌘⏎"), default.as_deref());
|
||||
} else {
|
||||
assert_eq!(None, default);
|
||||
}
|
||||
|
||||
// A reassigned shortcut resolves to its display string on every platform.
|
||||
ctx.set_custom_trigger(
|
||||
TOGGLE_MAXIMIZE_PANE_BINDING_NAME.to_owned(),
|
||||
Trigger::Keystrokes(vec![Keystroke::parse("cmd-shift-M").unwrap()]),
|
||||
);
|
||||
|
||||
let displayed_keybinding = if OperatingSystem::get().is_mac() {
|
||||
"⇧⌘M"
|
||||
} else {
|
||||
"Shift Logo M"
|
||||
};
|
||||
assert_eq!(
|
||||
Some(displayed_keybinding),
|
||||
keybinding_name_to_display_string(TOGGLE_MAXIMIZE_PANE_BINDING_NAME, ctx)
|
||||
.as_deref()
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_terminal_page_scroll_bindings_are_editable() {
|
||||
App::test((), |mut app| async move {
|
||||
app.update(terminal::init);
|
||||
|
||||
app.update(|ctx| {
|
||||
let page_up = ctx
|
||||
.editable_bindings()
|
||||
.find(|binding| binding.name == "terminal:scroll_up_one_page")
|
||||
.and_then(|binding| trigger_to_keystroke(binding.trigger));
|
||||
let page_down = ctx
|
||||
.editable_bindings()
|
||||
.find(|binding| binding.name == "terminal:scroll_down_one_page")
|
||||
.and_then(|binding| trigger_to_keystroke(binding.trigger));
|
||||
|
||||
assert_eq!(page_up, Keystroke::parse("pageup").ok());
|
||||
assert_eq!(page_down, Keystroke::parse("pagedown").ok());
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user