From 32e3d7b7fd215efd021d8869207b018edd0c2c83 Mon Sep 17 00:00:00 2001 From: Ogulcan Celik Date: Fri, 26 Jun 2026 18:13:31 +0300 Subject: fix: compact indexed keybind help ranges refs #817 --- src/ui.rs | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'src/ui.rs') diff --git a/src/ui.rs b/src/ui.rs index 71c11482..041cb232 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -1257,4 +1257,39 @@ mod tests { assert!(rendered_help.contains("open lazygit")); assert!(rendered_help.contains("custom command")); } + + #[test] + fn keybind_help_compacts_multiple_indexed_ranges() { + let config: crate::config::Config = toml::from_str( + r#" +[keys] +switch_tab = ["prefix+1..9", "alt+1..9"] +switch_workspace = "ctrl+1..9" +"#, + ) + .expect("config parses"); + + let mut app = crate::app::state::AppState::test_new(); + app.keybinds = config.keybinds(); + + let workspace_tab = keybind_help_groups(&app) + .into_iter() + .find(|(name, _)| *name == "workspaces / tabs") + .expect("workspace tab group") + .1; + + let switch_tab_key = workspace_tab + .iter() + .find(|(_, label)| label.as_ref() == "switch tab 1-9") + .map(|(key, _)| key.as_str()) + .expect("switch tab help entry"); + let switch_workspace_key = workspace_tab + .iter() + .find(|(_, label)| label.as_ref() == "switch workspace 1-9") + .map(|(key, _)| key.as_str()) + .expect("switch workspace help entry"); + + assert_eq!(switch_tab_key, "prefix+1..9 / alt+1..9"); + assert_eq!(switch_workspace_key, "ctrl+1..9"); + } } -- cgit v1.2.3