Skip to content

[Repo Assist] Truncate long cell values in FSI/ToString output — closes #570#646

Merged
dsyme merged 3 commits intomasterfrom
repo-assist/improve-fsi-column-width-truncation-570-f50f7487ddaa1a90
Mar 18, 2026
Merged

[Repo Assist] Truncate long cell values in FSI/ToString output — closes #570#646
dsyme merged 3 commits intomasterfrom
repo-assist/improve-fsi-column-width-truncation-570-f50f7487ddaa1a90

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

🤖 Repo Assist — implementing feature requested by @dsyme in #570.

Summary

Closes #570. When a series or frame is printed in FSI (or via .Format()/.ToString()), cell values longer than 50 characters are now truncated with "...", preventing a single long string from making an entire column unreadably wide.

Root Cause / Motivation

The existing formatTable already does per-column PadRight alignment, but it used the raw (uncapped) cell lengths to compute column widths. A single value of length 200 would make the whole column 201 characters wide, completely destroying readability. This was reported in #570 with a working proof-of-concept.

Fix

Added two changes to Formatting module in src/Deedle/Common/Common.fs:

  1. MaxCellWidth = 50 — new configurable constant (consistent with the suggestion in Make fsi print more beautiful #570 and pandas' default display width).
  2. truncateCell — private helper that clips strings exceeding MaxCellWidth and appends "...".
  3. Modified formatTable — builds a clipped 2D array before computing column widths and padding, so alignment is computed on the capped values.
let MaxCellWidth = 50

let private truncateCell (s:string) =
    if s.Length > MaxCellWidth then s.Substring(0, MaxCellWidth - 3) + "..."
    else s

let formatTable ((redacted) =
    ...
    let clipped = Array2D.init rows columns (fun r c -> truncateCell data.[r, c])
    // compute widths from clipped, then PadRight

The change is surgical — only formatTable is touched. FormatStrings and the rest of the pipeline are unchanged.

Trade-offs

  • Values ≥ 50 chars are truncated in display only; the underlying data is unaffected.
  • The 50-char limit is a constant, not runtime-configurable. If demand arises, MaxCellWidth can be made mutable (like RowStartItemCount) in a follow-up.

Test Status

✅ All 615 tests pass on Linux (dotnet test tests/Deedle.Tests/Deedle.Tests.fsproj -c Release).

3 new formatting tests added:

  • series with long string values truncates at MaxCellWidth
  • frame with long string values truncates at MaxCellWidth
  • series short values are not truncated

Generated by Repo Assist ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@30f2254f2a7a944da1224df45d181a3f8faefd0d

Add a MaxCellWidth constant (50 chars) to Formatting module and apply
it in formatTable. Cell values longer than 50 characters are clipped
and '...' appended, preventing a single long string from making an
entire column unreadably wide.

Column widths are now computed from clipped values, so the padding
remains tight. Short values are unaffected. The 50-char limit is
consistent with the pandas default and with the limit suggested in #570.

Tests: added 3 new formatting tests (long series values, long frame
values, short values not truncated). All 615 tests pass.

Co-authored-by: Copilot <[email protected]>
@dsyme dsyme marked this pull request as ready for review March 18, 2026 15:14
@dsyme dsyme merged commit 16c3edd into master Mar 18, 2026
2 checks passed
@dsyme dsyme deleted the repo-assist/improve-fsi-column-width-truncation-570-f50f7487ddaa1a90 branch March 18, 2026 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make fsi print more beautiful

1 participant