Fix window move: insert at boundaries instead of swap #3

Merged
forgejo_admin merged 1 commit from 1-fix-window-move-insert into main 2026-03-26 07:13:58 +00:00
Contributor

Summary

  • Override pain-control's < and > with external scripts using absolute indices
  • Normal case: one-step adjacent swap (same as stock pain-control)
  • Boundary case: bubble all the way to the other end (insert behavior, not swap)

Changes

  • .tmux.conf: Replace inline swap-window overrides with run-shell calls to external scripts
  • scripts/jump-to-front.sh: New — > at last position bubbles window to position 0
  • scripts/jump-to-back.sh: New — < at position 0 bubbles window to last position

Test Plan

  • Middle window + prefix > = one step right
  • Middle window + prefix < = one step left
  • Last window + prefix > = jump to front, everything shifts right
  • First window + prefix < = jump to back, everything shifts left
  • Focus follows the moved window in all cases

Review Checklist

  • Passed automated review-fix loop
  • No secrets committed
  • No unnecessary file changes
  • Commit messages are descriptive
  • Closes #1
  • Supersedes PR #2 which had incorrect fix (removed -d flag, broke repeat behavior)
## Summary - Override pain-control's `<` and `>` with external scripts using absolute indices - Normal case: one-step adjacent swap (same as stock pain-control) - Boundary case: bubble all the way to the other end (insert behavior, not swap) ## Changes - `.tmux.conf`: Replace inline `swap-window` overrides with `run-shell` calls to external scripts - `scripts/jump-to-front.sh`: New — `>` at last position bubbles window to position 0 - `scripts/jump-to-back.sh`: New — `<` at position 0 bubbles window to last position ## Test Plan - [ ] Middle window + `prefix >` = one step right - [ ] Middle window + `prefix <` = one step left - [ ] Last window + `prefix >` = jump to front, everything shifts right - [ ] First window + `prefix <` = jump to back, everything shifts left - [ ] Focus follows the moved window in all cases ## Review Checklist - [ ] Passed automated review-fix loop - [ ] No secrets committed - [ ] No unnecessary file changes - [ ] Commit messages are descriptive ## Related - Closes #1 - Supersedes PR #2 which had incorrect fix (removed `-d` flag, broke repeat behavior)
Override pain-control's < and > with external scripts that use
absolute indices. Normal case: one-step adjacent swap. Boundary
case (position 0 or last): bubble all the way to the other end,
producing insert behavior instead of a disorienting two-window swap.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Author
Contributor

PR #3 Review

DOMAIN REVIEW

Tech stack: POSIX shell scripts + tmux configuration (dotfiles repo).

Shell correctness: Both scripts are clean POSIX /bin/sh. Variables are properly quoted, arithmetic uses $((...)), no word-splitting or globbing risks. No shellcheck violations detected.

Tmux integration: The approach of using run-shell to call external scripts is sound. The swap-then-select pattern correctly maintains focus on the moved window.

Non-contiguous window index assumption: Both scripts assume window indices are contiguous (0, 1, 2, ..., N). The normal-case swap uses arithmetic (current - 1 / current + 1), and the boundary-case loop increments/decrements by 1. If windows have gaps in numbering (e.g., 0, 1, 5 after closing window 2), swapping with a non-existent index will fail silently in tmux (swap-window to a non-existent target creates the target, effectively moving the window). This is actually safe in practice -- tmux's swap-window to a non-existent target index just moves the window there. However, the bubble loop would stop working correctly because it would leave gaps. Worth understanding but likely acceptable for a personal dotfiles repo where renumber-windows is typically on.

Repeat mode removed: The old bindings had -r (repeat prefix). The new run-shell bindings do not have -r, so each move requires pressing prefix again. This is a deliberate tradeoff noted in the PR body (PR #2's -d removal broke repeat). Acceptable -- the boundary wrap behavior is the primary goal.

BLOCKERS

None.

This is a dotfiles/tooling repo. The BLOCKER criteria (test coverage for new functionality, input validation, secrets, DRY in auth paths) do not apply in the traditional sense:

  • No user-facing application code requiring automated tests
  • No external user input to validate
  • No secrets or credentials
  • No auth/security paths

NITS

  1. DRY between scripts: jump-to-back.sh and jump-to-front.sh are structural mirrors. Could be a single move-window.sh accepting a direction argument. For two 18-line scripts in a dotfiles repo, this is purely cosmetic.

  2. Non-contiguous index resilience: If you ever turn off renumber-windows, the boundary bubble loop could behave unexpectedly. A more robust approach would iterate over actual window indices from tmux list-windows -F '#{window_index}' rather than arithmetic increment. Low priority for dotfiles.

  3. No shebang path portability note: #!/bin/sh is fine for Linux. If this dotfiles repo is ever used on macOS where /bin/sh is a thin zsh wrapper, behavior is identical for this code, but worth noting.

SOP COMPLIANCE

  • Branch named after issue (1-fix-window-move-insert references issue #1)
  • PR body follows template (Summary, Changes, Test Plan, Review Checklist, Related)
  • Related references plan slug -- N/A, standalone board-driven work, no plan. Correctly references "Closes #1" and notes supersession of PR #2
  • No secrets committed
  • No unnecessary file changes (3 files, all directly related to the fix)
  • Commit messages are descriptive (PR title is clear)

PROCESS OBSERVATIONS

  • Clean second attempt after PR #2 was identified as incorrect (removed -d flag, broke repeat). Good iteration discipline -- superseded the broken PR rather than force-pushing over it.
  • Test plan is manual (tmux keybinding verification), which is appropriate for dotfiles. No CI infrastructure expected.
  • Small, focused change: 41 additions, 5 deletions across 3 files. Low change failure risk.

VERDICT: APPROVED

## PR #3 Review ### DOMAIN REVIEW **Tech stack**: POSIX shell scripts + tmux configuration (dotfiles repo). **Shell correctness**: Both scripts are clean POSIX `/bin/sh`. Variables are properly quoted, arithmetic uses `$((...))`, no word-splitting or globbing risks. No shellcheck violations detected. **Tmux integration**: The approach of using `run-shell` to call external scripts is sound. The swap-then-select pattern correctly maintains focus on the moved window. **Non-contiguous window index assumption**: Both scripts assume window indices are contiguous (0, 1, 2, ..., N). The normal-case swap uses arithmetic (`current - 1` / `current + 1`), and the boundary-case loop increments/decrements by 1. If windows have gaps in numbering (e.g., 0, 1, 5 after closing window 2), swapping with a non-existent index will fail silently in tmux (swap-window to a non-existent target creates the target, effectively moving the window). This is actually safe in practice -- tmux's `swap-window` to a non-existent target index just moves the window there. However, the bubble loop would stop working correctly because it would leave gaps. Worth understanding but likely acceptable for a personal dotfiles repo where `renumber-windows` is typically on. **Repeat mode removed**: The old bindings had `-r` (repeat prefix). The new `run-shell` bindings do not have `-r`, so each move requires pressing prefix again. This is a deliberate tradeoff noted in the PR body (PR #2's `-d` removal broke repeat). Acceptable -- the boundary wrap behavior is the primary goal. ### BLOCKERS None. This is a dotfiles/tooling repo. The BLOCKER criteria (test coverage for new functionality, input validation, secrets, DRY in auth paths) do not apply in the traditional sense: - No user-facing application code requiring automated tests - No external user input to validate - No secrets or credentials - No auth/security paths ### NITS 1. **DRY between scripts**: `jump-to-back.sh` and `jump-to-front.sh` are structural mirrors. Could be a single `move-window.sh` accepting a direction argument. For two 18-line scripts in a dotfiles repo, this is purely cosmetic. 2. **Non-contiguous index resilience**: If you ever turn off `renumber-windows`, the boundary bubble loop could behave unexpectedly. A more robust approach would iterate over actual window indices from `tmux list-windows -F '#{window_index}'` rather than arithmetic increment. Low priority for dotfiles. 3. **No shebang path portability note**: `#!/bin/sh` is fine for Linux. If this dotfiles repo is ever used on macOS where `/bin/sh` is a thin zsh wrapper, behavior is identical for this code, but worth noting. ### SOP COMPLIANCE - [x] Branch named after issue (`1-fix-window-move-insert` references issue #1) - [x] PR body follows template (Summary, Changes, Test Plan, Review Checklist, Related) - [ ] Related references plan slug -- N/A, standalone board-driven work, no plan. Correctly references "Closes #1" and notes supersession of PR #2 - [x] No secrets committed - [x] No unnecessary file changes (3 files, all directly related to the fix) - [x] Commit messages are descriptive (PR title is clear) ### PROCESS OBSERVATIONS - Clean second attempt after PR #2 was identified as incorrect (removed `-d` flag, broke repeat). Good iteration discipline -- superseded the broken PR rather than force-pushing over it. - Test plan is manual (tmux keybinding verification), which is appropriate for dotfiles. No CI infrastructure expected. - Small, focused change: 41 additions, 5 deletions across 3 files. Low change failure risk. ### VERDICT: APPROVED
forgejo_admin deleted branch 1-fix-window-move-insert 2026-03-26 07:13:58 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ldraney/dotfiles!3
No description provided.