Skip to content

Table width calculation #486

@stuta

Description

@stuta

Description

Issue: Tables truncate unexpectedly unless both specific style and large word_wrap values are provided

Current Behavior:

  • Default settings: tables truncate (2 truncation characters found)
  • style='dark' alone: tables still truncate (2 truncation characters)
  • word_wrap=140 alone: tables still truncate (2 truncation characters)
  • style='dark', word_wrap=140: tables display properly (0 truncation characters)

Expected Behavior: Tables should display without truncation when provided adequate width, regardless of style choice

Root Cause Analysis:
In ansi/blockstack.go:65, the width calculation uses multiplication:

// Line 65 - Current implementation
return uint(ctx.options.WordWrap) - s.Indent()*s.Margin()

Example Calculation (with dark style, margin=2, indent=0):
- Current: 80 - (0 * 2) = 80 chars (too wide for complex tables)
- Proposed: 80 - 0 - 2 = 78 chars (more accurate width calculation)

Proposed Fix:
Change multiplication to addition:
// Proposed fix
return uint(ctx.options.WordWrap) - s.Indent() - s.Margin()

Test Case:
| Feature | Basic Plan | Professional Plan | Enterprise Plan | Description |
|---------|------------|-------------------|-----------------|-------------|
| **API Access** |Limited |Full REST API |Advanced GraphQL features | Programmatic access to all platform features |
| **Support** | Email only | Priority email + chat | 24/7 phone support | Different levels of customer support availability |

Impact: This change would provide more accurate table width calculations and prevent unexpected truncation with standard word_wrap values.

Is this the intended calculation method?

### Version

master

### Environment

all (osx)  / all (wezterm + Ghostty tested)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions