Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
fix(switch): suppress skim's alt-l/alt-h horizontal scroll in the picker (#3226)
Maximilian Roos7ac7656d063e
diff --git a/src/commands/picker/mod.rs b/src/commands/picker/mod.rsindex f429460e1..2613ed309 100644--- a/src/commands/picker/mod.rs+++ b/src/commands/picker/mod.rs@@ -1206,6 +1206,16 @@ pub fn handle_picker(// Preview toggle (alt-p shows/hides preview)// Note: skim doesn't support change-preview-window like fzf, only toggle"alt-p:toggle-preview".to_string(),+ // Suppress skim's default manual horizontal scroll (alt-h / alt-l map to+ // ScrollLeft / ScrollRight in its built-in keymap). `no_hscroll(true)`+ // above only zeros the *automatic* match-following shift; it doesn't gate+ // the manual `manual_hscroll` offset these keys push, so they still slide+ // each row's `display()` left under the fixed gutter — clipping the leading+ // worktree-status sigil (`+`/`@`/`^`/`/`/`|`) and the branch name with no+ // ellipsis. The row table is laid out to fit the pane, so there is nothing+ // to scroll to; ignore both.+ "alt-h:ignore".to_string(),+ "alt-l:ignore".to_string(),// Preview scrolling (half-page based on terminal height)format!("ctrl-u:preview-up({half_page})"),format!("ctrl-d:preview-down({half_page})"),diff --git a/tests/integration_tests/switch_picker.rs b/tests/integration_tests/switch_picker.rsindex 732575985..61926be15 100644--- a/tests/integration_tests/switch_picker.rs+++ b/tests/integration_tests/switch_picker.rs@@ -573,6 +573,44 @@ fn test_switch_picker_with_multiple_worktrees(mut repo: TestRepo) {});}+/// Alt-l / alt-h are skim's built-in horizontal-scroll keys (ScrollRight /+/// ScrollLeft). The picker binds both to `ignore` because each row's `display()`+/// owns its layout with a leading worktree-status sigil; an unbound alt-l slides+/// every row left, clipping that sigil gutter (`no_hscroll(true)` only gates the+/// automatic match-following shift, not the manual offset these keys push).+/// Pressing alt-l here must leave the list byte-for-byte unscrolled — the same+/// frame `test_switch_picker_with_multiple_worktrees` snapshots.+#[rstest]+fn test_switch_picker_alt_l_does_not_hscroll(mut repo: TestRepo) {+ repo.remove_fixture_worktrees();+ // Remove origin so snapshots don't show origin/main+ repo.run_git(&["remote", "remove", "origin"]);+ repo.add_worktree("feature-one");+ repo.add_worktree("feature-two");++ let env_vars = repo.test_env_vars();+ let result = exec_in_pty_capture_before_abort(+ wt_bin().to_str().unwrap(),+ &["switch"],+ repo.root_path(),+ &env_vars,+ &[+ ("", Some("feature-two")), // wait for items to render+ ("\x1bl", None), // Alt-l: ignored, must not scroll+ ("\x1bl", None), // a second press, still ignored+ ("\x1bh", None), // Alt-h: ignored too+ ],+ );++ assert_valid_abort_exit_code(result.exit_code);++ let (list, _preview) = result.panels();+ let settings = switch_picker_settings(&repo);+ settings.bind(|| {+ assert_snapshot!("switch_picker_alt_l_ignored_list", list);+ });+}+#[rstest]fn test_switch_picker_with_branches(mut repo: TestRepo) {repo.remove_fixture_worktrees();diff --git a/tests/snapshots/integration__integration_tests__switch_picker__switch_picker_alt_l_ignored_list.snap b/tests/snapshots/integration__integration_tests__switch_picker__switch_picker_alt_l_ignored_list.snapnew file mode 100644index 000000000..44d7ac6aa--- /dev/null+++ b/tests/snapshots/integration__integration_tests__switch_picker__switch_picker_alt_l_ignored_list.snap@@ -0,0 +1,9 @@+---+source: tests/integration_tests/switch_picker.rs+expression: list+---+>+ Branch Status HEAD± main↕ CI Age+> @ main ^ [TIME]+ + feature-one _ [TIME]+ + feature-two _ [TIME]