aboutsummaryrefslogtreecommitdiff
path: root/src/ui.rs
diff options
context:
space:
mode:
authorOgulcan Celik <ogulcancelik@gmail.com>2026-05-30 23:58:02 +0300
committerOgulcan Celik <ogulcancelik@gmail.com>2026-05-31 00:02:08 +0300
commitbdc189e32e7c9dd61811fe17e50ac171ca94c647 (patch)
tree730e0e14d571e9bb693ad583b02e24622e4258d4 /src/ui.rs
parentfc4e1bbf6b0fa2ec37445a5b72356514c7c6be6a (diff)
feat: support custom command descriptions
refs #362
Diffstat (limited to 'src/ui.rs')
-rw-r--r--src/ui.rs76
1 files changed, 66 insertions, 10 deletions
diff --git a/src/ui.rs b/src/ui.rs
index c9999a9a..b9d9827a 100644
--- a/src/ui.rs
+++ b/src/ui.rs
@@ -1019,23 +1019,79 @@ mod tests {
.1
.clone();
- assert!(workspace_tab.contains(&("unset".to_string(), "previous workspace")));
- assert!(workspace_tab.contains(&("unset".to_string(), "next workspace")));
- assert!(workspace_tab.contains(&("unset".to_string(), "previous agent")));
- assert!(workspace_tab.contains(&("unset".to_string(), "next agent")));
- assert!(workspace_tab.contains(&("unset".to_string(), "focus agent 1-9")));
- assert!(workspace_tab.contains(&("unset".to_string(), "switch workspace 1-9")));
+ assert!(workspace_tab
+ .iter()
+ .any(|(key, label)| key == "unset" && label.as_ref() == "previous workspace"));
+ assert!(workspace_tab
+ .iter()
+ .any(|(key, label)| key == "unset" && label.as_ref() == "next workspace"));
+ assert!(workspace_tab
+ .iter()
+ .any(|(key, label)| key == "unset" && label.as_ref() == "previous agent"));
+ assert!(workspace_tab
+ .iter()
+ .any(|(key, label)| key == "unset" && label.as_ref() == "next agent"));
+ assert!(workspace_tab
+ .iter()
+ .any(|(key, label)| key == "unset" && label.as_ref() == "focus agent 1-9"));
+ assert!(workspace_tab
+ .iter()
+ .any(|(key, label)| key == "unset" && label.as_ref() == "switch workspace 1-9"));
assert!(panes
.iter()
- .any(|(key, label)| key == "prefix+h" && *label == "focus pane left"));
+ .any(|(key, label)| key == "prefix+h" && label.as_ref() == "focus pane left"));
assert!(panes
.iter()
- .any(|(key, label)| key == "prefix+j" && *label == "focus pane down"));
+ .any(|(key, label)| key == "prefix+j" && label.as_ref() == "focus pane down"));
assert!(panes
.iter()
- .any(|(key, label)| key == "prefix+k" && *label == "focus pane up"));
+ .any(|(key, label)| key == "prefix+k" && label.as_ref() == "focus pane up"));
assert!(panes
.iter()
- .any(|(key, label)| key == "prefix+l" && *label == "focus pane right"));
+ .any(|(key, label)| key == "prefix+l" && label.as_ref() == "focus pane right"));
+ }
+
+ #[test]
+ fn keybind_help_shows_custom_command_descriptions() {
+ let mut app = crate::app::state::AppState::test_new();
+ app.keybinds.custom_commands = vec![
+ crate::config::CustomCommandKeybind {
+ bindings: crate::config::ActionKeybinds::prefix("alt+g"),
+ label: "prefix+alt+g".to_string(),
+ command: "lazygit".to_string(),
+ action: crate::config::CustomCommandAction::Pane,
+ description: Some("open lazygit".to_string()),
+ },
+ crate::config::CustomCommandKeybind {
+ bindings: crate::config::ActionKeybinds::prefix("alt+h"),
+ label: "prefix+alt+h".to_string(),
+ command: "echo hello".to_string(),
+ action: crate::config::CustomCommandAction::Shell,
+ description: None,
+ },
+ ];
+
+ let groups = keybind_help_groups(&app);
+ let custom = groups
+ .iter()
+ .find(|(name, _)| *name == "custom")
+ .expect("custom group")
+ .1
+ .clone();
+ assert!(custom
+ .iter()
+ .any(|(key, label)| key == "prefix+alt+g" && label.as_ref() == "open lazygit"));
+ assert!(custom
+ .iter()
+ .any(|(key, label)| key == "prefix+alt+h" && label.as_ref() == "custom command"));
+
+ let rendered_help = keybind_help_lines(&app)
+ .into_iter()
+ .flat_map(|(_, line)| line.spans)
+ .map(|span| span.content.into_owned())
+ .collect::<Vec<_>>()
+ .join("");
+ assert!(rendered_help.contains("open lazygit"));
+ assert!(rendered_help.contains("custom command"));
}
}