Repository navigation
Word-wrap-aware automatic row height (#1969) - #2049
Merged
Merged
Conversation
Closes storytold#1969 Co-Authored-By: Claude <noreply@anthropic.com>
jcagudelo12
added a commit
to jcagudelo12/gridcraft
that referenced
this pull request
Nov 2, 2026
…#1969) The row height of a wrapped cell counts its word-wrapped lines (storytold#2049) with word widths the front end measures in the font the grid draws with (Session::text_width, the measurer AutoFit Column Width already uses), at the width the grid wraps at: 2.5 px padding a side, the indent and a filter button. egui measures at the screen's scale, so the line breaks match the grid's on scaled displays too. Without a front end (CLI, MCP) word widths stay estimated. The line count follows egui's wrapping: a word stays on a line only if the space after it fits too, a line may end after a dash (UAX storytold#14), and a word wider than the column breaks between characters rather than by its width over the column's. Session::refit_wrapped_rows refits the rows of wrapped text once a new font set is active (startup, workbook fonts bound). Rows only grow, custom heights are kept, and it is not an edit. Undo and redo restore the heights they saved, with no refit.
jcagudelo12
added a commit
to jcagudelo12/gridcraft
that referenced
this pull request
Nov 2, 2026
…#1969) The row height of a wrapped cell counts its word-wrapped lines (storytold#2049) with word widths the front end measures in the font the grid draws with (Session::text_width, the measurer AutoFit Column Width already uses), at the width the grid wraps at: 2.5 px padding a side, the indent and a filter button. Without a front end (CLI, MCP) word widths stay estimated. The line count follows egui's line breaking (its default SimpleLineBreaker), so the row has one line per line the grid draws: - A line may end after a space, a hyphen or other ASCII punctuation, not after an en or em dash. A line that runs over ends at its last break of the lowest of those kinds. - egui checks each character: one that runs over ends the line there when it has no break, so a word wider than the column breaks between characters, and that character stays on the next line. A line may run half a point past the width (round_output_to_gui). - egui starts each character on a whole physical pixel, rounded down. The front end gives the screen's scale (Session::text_pixels_per_point), so the count matches the grid at 1.5 or 1.6 px/pt too. Session::refit_wrapped_rows refits the rows of wrapped text once a new font set is active (startup, workbook fonts bound). Rows only grow, custom heights are kept, and it is not an edit. Undo and redo restore the heights they saved, with no refit.
jcagudelo12
added a commit
to jcagudelo12/gridcraft
that referenced
this pull request
Nov 18, 2026
…#1969) The row height of a wrapped cell counts its word-wrapped lines (storytold#2049) with word widths the front end measures in the font the grid draws with (Session::text_width, the measurer AutoFit Column Width already uses), at the width the grid wraps at: 2.5 px padding a side, the indent and a filter button. Without a front end (CLI, MCP) word widths stay estimated. The line count follows egui's line breaking (its default SimpleLineBreaker), so the row has one line per line the grid draws: - A line may end after a space, a hyphen or other ASCII punctuation, not after an en or em dash. A line that runs over ends at its last break of the lowest of those kinds. - egui checks each character: one that runs over ends the line there when it has no break, so a word wider than the column breaks between characters, and that character stays on the next line. A line may run half a point past the width (round_output_to_gui). - egui starts each character on a whole physical pixel, rounded down. The front end gives the screen's scale (Session::text_pixels_per_point), so the count matches the grid at 1.5 or 1.6 px/pt too. Session::refit_wrapped_rows refits the rows of wrapped text once a new font set is active (startup, workbook fonts bound). Rows only grow, custom heights are kept, and it is not an edit. Undo and redo restore the heights they saved, with no refit.
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.
Problem (#1969)
auto_row_heightcounted a wrapped cell's lines as total-text-width ÷ column-width, as if words could split anywhere. The grid word-wraps whole words (eguiLayoutJob), so every drawn line ends early at the last word that fits — a narrow column needs more lines than the estimate, and the row cut off the tail of the text.Fix
wrapped_line_countincrates/engine/src/cmd/mod.rs: a greedy word-wrap simulation over the sameapprox_text_widthcharacter estimates — words that don't fit move to the next line whole, a word wider than the column fills the current line then breaks mid-word across lines (what egui does), and inter-word spaces are counted. Multi-line (Alt+Enter) text runs the simulation per line, as before.Tests
crates/engine/tests/wrap_row_height.rs:wrapped_row_fits_word_wrapped_lines— six-char words in a 10-char column: word wrap needs 4 lines, the old estimate said 3. Fails on main.issue_repro_nasa_sentence— the issue's exact NASA sentence in a 12-char column. Fails on main.Full
gridcraft-enginesuite green, clippy 0 warnings, fmt clean.Co-Authored-By: Claude noreply@anthropic.com
Summary by CodeRabbit
Bug Fixes
Tests