Skip to content

scrolling: delete unreachable wrap branch - #9

Merged
barlevalon merged 1 commit into
mainfrom
review-scrolling-slice
Aug 22, 2026
Merged

scrolling: delete unreachable wrap branch#9
barlevalon merged 1 commit into
mainfrom
review-scrolling-slice

Conversation

@barlevalon

Copy link
Copy Markdown
Owner

Summary

  • delete the unreachable secondary wrap branch in scrolling_text
  • keep the duplicated text buffer as the single cycle-boundary mechanism
  • add focused scrolling boundary tests, including empty padding

Proof

After the early return, let text length be L, width be W, padding length be P, and normalized start position be S. The scrolling path has L > W, so W <= L - 1. The caller provides a nonnegative offset and width of at least 4, so for cycle length L + P, 0 <= S <= L + P - 1.

Therefore:

S + W <= (L + P - 1) + (L - 1) = 2L + P - 2

The duplicated buffer ${text}${padding}${text} has length 2L + P, so every visible slice ends before that buffer ends. The deleted fallback branch cannot execute.

Behavior preservation

The old reachable path and the simplified implementation both run:

printf '%.*s\n' "$max_width" "${padded_text:$start_pos}"

The duplicated text still handles crossing the conceptual cycle boundary. No output behavior changes.

Tests

  • bash -n nowplaying.tmux scripts/*.sh
  • ./scripts/test.sh
  • shellcheck nowplaying.tmux scripts/*.sh
  • direct checks for exact fit, initial position, text-to-padding crossing, padding start, final cycle offset, exact cycle wrap, large offset normalization, and empty padding

All checks pass.

Residual risks

  • Direct malformed width or offset inputs remain unsupported; the production caller validates width and generates a numeric, nonnegative offset.
  • Bash string length and slicing do not model terminal-cell width for combining or double-width Unicode characters; this is pre-existing.
  • Bash 3.2 source compatibility is preserved, but an actual Bash 3.2 executable was unavailable for runtime validation.

@barlevalon
barlevalon force-pushed the review-scrolling-slice branch from 0a01fc1 to 3a78cec Compare August 22, 2026 15:48
@barlevalon
barlevalon merged commit a19b178 into main Aug 22, 2026
2 checks passed
@barlevalon
barlevalon deleted the review-scrolling-slice branch August 22, 2026 15:49
@barlevalon
barlevalon restored the review-scrolling-slice branch August 22, 2026 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant