feat(format): add NoWrapCell for data-driven column minimum widths#574
feat(format): add NoWrapCell for data-driven column minimum widths#574
Conversation
Replace the hardcoded minColumnWidth=4 (for NULL marker) with a general NoWrapCell mechanism that marks cells whose content should preferably not be wrapped. - Add NoWrapCell type wrapping any Cell via composition - Add deriveColumnHints() to compute PreferredMinWidth per column from NoWrapCell instances - Update ColumnHint with PreferredMinWidth field (replaces NoWrap bool) - Add applyColumnFloors() shared helper with soft degradation: uses preferred min when budget allows, falls back to hard minimum (1) when preferred mins exceed available width - Update spannerRowToRow() to wrap NULL cells as NoWrapCell - Reduce minColumnWidth from 4 to 1 (meaningful minimum is now data-driven) - All three strategies (Greedy, Marginal, Proportional) use the shared helper Fixes #567 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the table formatting capabilities by introducing a data-driven approach to column width management. It allows specific cell contents to express a preference against wrapping, ensuring that short, important values remain intact when possible. The system now dynamically calculates preferred minimum widths and applies them with a soft degradation mechanism, providing a more intelligent and visually appealing layout that adapts gracefully to available screen space, moving away from rigid, hardcoded minimums. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
Code Metrics Report📊 View detailed coverage report (available for 7 days)
Details | | main (f3a08a1) | #574 (cf150bc) | +/- |
|---------------------|----------------|----------------|--------|
+ | Coverage | 70.7% | 70.8% | +0.1% |
| Files | 75 | 75 | 0 |
| Lines | 6988 | 7007 | +19 |
+ | Covered | 4945 | 4967 | +22 |
+ | Code to Test Ratio | 1:1.2 | 1:1.3 | +0.0 |
| Code | 16241 | 16274 | +33 |
+ | Test | 21086 | 21183 | +97 |
+ | Test Execution Time | 2m24s | 1m9s | -1m15s |Code coverage of files in pull request scope (90.8% → 91.7%)
Reported by octocov |
There was a problem hiding this comment.
Code Review
This pull request introduces a NoWrapCell type and a PreferredMinWidth concept to enhance column width calculation in table formatting. The minColumnWidth is reduced from 4 to 1, and a new mechanism is implemented to identify cells that should preferably not be wrapped (e.g., "NULL", "true", "false"). The system now calculates a PreferredMinWidth for each column based on the maximum width of its NoWrapCell contents. Column width strategies have been updated to utilize these PreferredMinWidth hints, applying them as a soft constraint when space allows, and gracefully degrading to the hard minColumnWidth of 1 if the total preferred width exceeds available screen space. This ensures important short values remain intact while maintaining flexibility in layout. New unit and integration tests have been added to validate this behavior, particularly for NULL values.
|
/gemini summary |
Summary of ChangesThis pull request refactors the column width calculation logic to be data-driven, moving away from a hardcoded minimum width. It introduces a Highlights
Changelog
Activity
|
Summary
NoWrapCelltype that wraps anyCellto indicate its content should preferably not be wrappedderiveColumnHints()to computePreferredMinWidthper column fromNoWrapCellinstancesColumnHintwithPreferredMinWidthfield (replaces reservedNoWrap bool)applyColumnFloors()shared helper with soft degradation: uses preferred min when budget allows, falls back to hard minimum when it doesn't fitNoWrapCellinspannerRowToRow()minColumnWidthfrom 4 to 1 (meaningful minimum is now data-driven)Motivation
The hardcoded
minColumnWidth = 4was implicit knowledge that NULL is 4 characters. This change makes the constraint data-driven and soft: columns withNoWrapCellvalues prefer to be wide enough to avoid wrapping those values, but degrade gracefully when screen space is insufficient.Test plan
NoWrapCelltype: Format/RawText delegation, WithText preserves wrapper, IsNoWrap helperderiveColumnHints: computes correct PreferredMinWidth from NoWrapCell widthsmake checkpasses (test + lint + fmt-check)Fixes #567
🤖 Generated with Claude Code