Repository navigation
text_view: Keep narrow table columns on one line - #3399
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…finements Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
linruohan
pushed a commit
to linruohan/gpui-component
that referenced
this pull request
Oct 9, 2026
## Description Short table columns in `TextView` often wrap a single trailing character onto its own line (`冷启动(毫秒` + `)`, `Memo` + `ry`). The wrap layout sized columns by UTF-8 byte length, and the scroll layout shrank every column by the same ratio, so a column that nearly fit lost its last character. Both layouts now size columns from measured text width. When the table is wider than its frame, narrow columns keep their full width and only the widest ones shrink and wrap. Widths are also rounded up to the device pixel, and headers are measured with the `table_head` / `table_cell` styles they render with. **Behavior change:** column widths in the default wrap layout change for most tables. Not in this PR: breaks before full-width closing punctuation (`)`) and after opening punctuation (`(`) come from GPUI's line wrapper and need a GPUI change. The `markdown_table` example gets a "Column fitting" section with the same table in Chinese and English. ## Screenshot `cargo run -p markdown_table` at 640px wide. | Table | Before | After | | --- | --- | --- | | English, wrap | <img width="640" height="440" alt="table-en-before-wrap" src="https://github.com/user-attachments/assets/f842cb34-65ee-4190-aa49-b1b2d8c93c36" /> | <img width="640" height="440" alt="table-en-after-wrap" src="https://github.com/user-attachments/assets/ddf5ac5c-1373-4b76-a9db-61c1108ecfcb" /> | | English, scroll | <img width="640" height="440" alt="table-en-before-adaptive" src="https://github.com/user-attachments/assets/e0369e63-7af5-46e7-9d50-8341d0b7f3d9" /> | <img width="640" height="440" alt="table-en-after-adaptive" src="https://github.com/user-attachments/assets/6ea609ca-992f-4be7-aa2d-45da8ed64be6" /> | | Chinese, wrap | <img width="640" height="440" alt="table-zh-before-wrap" src="https://github.com/user-attachments/assets/316ec94e-59c5-469f-be10-d296e5ad6c0e" /> | <img width="640" height="440" alt="table-zh-after-wrap" src="https://github.com/user-attachments/assets/663589de-c591-4871-911f-91a8558b3d3a" /> | | Chinese, scroll | <img width="640" height="440" alt="table-zh-before-adaptive" src="https://github.com/user-attachments/assets/ac55f40e-09a3-476f-ac00-65d8f816a73b" /> | <img width="640" height="440" alt="table-zh-after-adaptive" src="https://github.com/user-attachments/assets/d0d6ab7a-72b4-4813-aecc-6d4700aa7c71" /> | ## How to Test - `cargo test -p gpui-base --lib`: passed. The new `table_keeps_narrow_columns_on_one_line_while_wide_ones_wrap` fails on the parent commit. - `cargo run -p markdown_table`, scroll to "6. Column fitting", switch layouts and narrow the window. ## Checklist - [x] I have read the [CONTRIBUTING](../CONTRIBUTING.md) document and followed the guidelines. - [x] Reviewed the changes in this PR and confirmed AI generated code (If any) is accurate. - [x] Passed `cargo run` for story tests related to the changes. - [ ] Tested macOS, Windows and Linux platforms performance (if the change is platform-specific) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Short table columns in
TextViewoften wrap a single trailing character onto its own line (冷启动(毫秒+),Memo+ry). The wrap layout sized columns by UTF-8 byte length, and the scroll layout shrank every column by the same ratio, so a column that nearly fit lost its last character.Both layouts now size columns from measured text width. When the table is wider than its frame, narrow columns keep their full width and only the widest ones shrink and wrap. Widths are also rounded up to the device pixel, and headers are measured with the
table_head/table_cellstyles they render with.Behavior change: column widths in the default wrap layout change for most tables.
Not in this PR: breaks before full-width closing punctuation (
)) and after opening punctuation (() come from GPUI's line wrapper and need a GPUI change.The
markdown_tableexample gets a "Column fitting" section with the same table in Chinese and English.Screenshot
cargo run -p markdown_tableat 640px wide.How to Test
cargo test -p gpui-base --lib: passed. The newtable_keeps_narrow_columns_on_one_line_while_wide_ones_wrapfails on the parent commit.cargo run -p markdown_table, scroll to "6. Column fitting", switch layouts and narrow the window.Checklist
cargo runfor story tests related to the changes.