Skip to content

fix(output): align ANSI-coloured cells under --table-style; add lrt script - #85

Merged
TimelordUK merged 2 commits into
mainfrom
fix/table-style-ansi-width
Sep 13, 2026
Merged

TimelordUK merged 2 commits into
mainfrom
fix/table-style-ansi-width

Conversation

@TimelordUK

Copy link
Copy Markdown
Owner

Summary

Fix: coloured cells misaligned under --table-style. Every style except default renders through comfy-table, which measured cell width in bytes. ANSI_COLOR('yellow', '3h') was padded as if it were 11 columns wide, so borders and columns drifted. The default renderer already used display width.

  • Enable comfy-table's custom_styling feature, which strips ANSI escapes when measuring width. No Rust code changes.

New: scripts/lrt.ps1. A PowerShell ls -alrt built on the FILE CTE:

  • separate date and time columns in local time
  • a coloured, human-readable age (45s / 12m / 3h / 8d)
  • FORMAT_BYTES sizes and names coloured by file type
  • options for recursion (-r), glob filters (-g), directories (-d) and table style (-style, default plain)

Tests

  • New cases in tests/python_tests/test_table_output_alignment.py: coloured cells in all 13 table styles, plus four styles with --max-col-width truncation. The width checker now ignores ANSI escapes.
  • Without the feature, 15 of the new cases fail; only the two default-style cases pass, as expected.
  • ./run_all_tests.sh passes. The one smoke failure, expander_rewriters (a GROUP BY error in query 7), is unrelated to table rendering.

Known limitation (not in this PR)

The date functions work in UTC, and there is no function to convert to local time. lrt shifts by today's UTC offset, so files from the other side of a DST change show an hour out. A follow-up could add a local-time function or an optional time-zone argument to FORMAT_DATE.

🤖 Generated with Claude Code

https://claude.ai/code/session_01UT2eunuVZv5L2tBTs2zStB

TimelordUK and others added 2 commits September 13, 2026 20:58
Every --table-style except the default renders through comfy-table, which
measured cell width in bytes, so ANSI_COLOR output was padded as if the
escape codes were visible and the table borders drifted. The default
renderer already sized columns by display width.

Enable comfy-table's custom_styling feature, which strips escapes when
measuring. Tests cover coloured cells in all 13 styles, with and without
--max-col-width truncation; 15 of them fail without the feature.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01UT2eunuVZv5L2tBTs2zStB
PowerShell function listing the most recently modified files through the
FILE CTE: separate date and time columns in local time, a coloured
human-readable age, FORMAT_BYTES sizes and names coloured by type.
Supports recursion, glob filters, directories and any --table-style.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01UT2eunuVZv5L2tBTs2zStB
@TimelordUK
TimelordUK merged commit c7d414b into main Sep 13, 2026
8 checks passed
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