Skip to content

Use full terminal width in auto-detected wrap mode - #952

Open
RubMaker wants to merge 3 commits into
charmbracelet:masterfrom
RubMaker:feat/auto-width-no-120-cap
Open

Use full terminal width in auto-detected wrap mode#952
RubMaker wants to merge 3 commits into
charmbracelet:masterfrom
RubMaker:feat/auto-width-no-120-cap

Conversation

@RubMaker

Copy link
Copy Markdown

Summary

This PR removes the 120-column clamp from Glow's auto-detected CLI wrap width path.

Why

Issue #942 requests behavior equivalent to automatically using terminal width (like -w $COLUMNS) without requiring shell-specific variables or external commands.

Glow already had terminal width auto-detection, but the detected value was capped at 120 columns, which caused premature wrapping on wide terminals.

What changed

  1. Removed the 120-column cap in auto-detected width resolution.
  2. Refactored width resolution into a small helper (resolveWidth) for clearer logic and testability.
  3. Added table-driven tests for width resolution behavior.
  4. Clarified README wording for default wrap behavior when -w is not provided.

Behavior

  • Explicit -w/--width still has highest priority.
  • -w 0 behavior is unchanged.
  • Non-TTY / detection-failure fallback remains unchanged.
  • No changes to long-word/hard-wrap behavior.
  • No TUI layout behavior changes.

Tests

  • Added unit tests in main_width_test.go covering:
    • explicit width
    • explicit zero width
    • auto-detected width (including >120)
    • detection fallback
    • non-TTY fallback
  • Ran:
    • go test -count=1 ./...

Closes

Closes #942

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.

Feature Request: auto detect terminal width

1 participant