Use CSS Grid and Flexbox for editor layout - #950
Draft
Michael Greene (mgreenegit) wants to merge 4 commits into
Draft
Michael Greene (mgreenegit) wants to merge 4 commits into
Michael Greene (mgreenegit) wants to merge 4 commits into
Conversation
Michael Greene (mgreenegit)
marked this pull request as ready for review
September 11, 2026 21:55
Leonard Hecker (lhecker)
requested changes
Sep 16, 2026
Leonard Hecker (lhecker)
left a comment
Member
There was a problem hiding this comment.
I don't believe this is the right direction. My intention was to implement CSS grid & flexbox support in the near term (or at least a subset of those). Like this: https://jsfiddle.net/vkubqc4d/
Keep native widgets as measured leaves and styles outside the arena. Cover CSS geometry, legacy boundaries, clipping, and intrinsic measurement. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Compose a Grid application root and Flexbox editor/search column instead of subtracting fixed row reservations. Test actual draw geometry and focus across search modes, document states, and small viewports. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Michael Greene (mgreenegit)
force-pushed
the
fix/editor-height-small-viewports
branch
from
September 17, 2026 14:00
53b2842 to
9321dee
Compare
Apply the exact line wrapping reported by the upstream formatting check without changing layout behavior. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Compare the full saved buffer using the existing serialization helper. Unix documents intentionally append a final newline; this is not a layout or focus regression. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Michael Greene (mgreenegit)
marked this pull request as draft
September 17, 2026 15:04
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.
Direction
This revision replaces the earlier
attr_fill_heightproposal in response tothe requested CSS Grid/Flexbox direction.
It uses Taffy to execute CSS Grid and Flexbox layout algorithms, rather than
introducing another hand-written remaining-height allocator.
The application is deliberately small: lay out the existing menu, editor/search
area, and status bar. No console, provider, AI, command, setting, or stylesheet
language is introduced.
Problem
The editor currently reconstructs its available height by subtracting fixed
reservations: 2 rows normally, 4 with Search, and 5 with Replace. This duplicates
information already present in the UI tree and can request a negative intrinsic
height in short viewports.
The adjacent TODO says:
This change removes that reservation table and TODO. The parent layout now sizes
the surrounding controls from their measured content and allocates the editor
the remaining space.
Small first use of both layout models
flexible middle row. This follows the structure of
the review's example.
region and a growing/shrinking document region. Search and Replace contribute
their actual measured heights; the document code no longer knows those values.
minmax(0, 1fr), and thedocument flex item has a zero minimum and zero flex basis. This is intentional:
bare
1frhas an automatic minimum and can allow content to dictate the track'sminimum size. The document must be allowed to shrink to zero when space runs out.
An empty placeholder participates in the same layout when no document is open.
The new container preserves focus inheritance into the text area.
This does not make arbitrarily small terminals fully usable. Fixed/content-sized
controls can still overflow; the existing terminal clipping boundary remains in
effect. The safety goal is nonnegative document geometry, not a new overflow UI.
Implementation boundary
Context::attr_css_styleopts a node into typed CSS geometry. Styled blocks becomenested Taffy containers; their unstyled widget children remain intrinsic boxes.
Unmarked blocks, tables, scrollareas, rendering, and event handling retain their
existing implementations. Existing floating nodes stay outside the normal stack.
Taffy solves a frame-local tree and rounds positions/sizes to terminal cells. The
adapter maps its results back to Edit's rectangles, keeping unclipped origins
separate from visible bounds so nested overflow does not move descendants.
Style values own allocations, so they live on
Context, which is droppednormally. Arena nodes retain only indices. The arena-allocated/copied
NodeandTreetypes do not acquire owning fields.The public surface is intentionally a typed geometry API, not a CSS parser or
browser renderer:
single-line; textareas retain Edit's own wrapping and scrolling. This is not
CSS text reflow or a new implementation of widget measurement.
the adapter for existing TUI padding/border/scrollbar insets; callers use
attr_borderfor terminal borders.replaced. Their inset conversion now also prevents negative inner dimensions.
Dependency and size cost
This introduces Taffy 0.14.0 (MIT), pinned for this proposal, with default
features disabled and only
std,grid,flexbox, andtaffy_treeenabled.Its declared Rust minimum is 1.71, below this workspace's 1.93 minimum.
The lockfile gains three packages:
taffy,arrayvec, andslotmap; other neededpackages were already present. No unrelated dependency versions are updated.
The binary-size cost is material and should be part of the review. With the
same local Windows x86-64 managed Rust toolchain and normal release profile:
826b4c0These are executable sizes, not downloads or installer sizes. This proposal does
not claim that a small adapter makes the dependency free. It makes the tradeoff
explicit: use an existing CSS layout implementation rather than maintain a
partial local reimplementation. Layout latency and allocation overhead have not
been characterized.
Verification
The replacement was developed and tested in an isolated source snapshot inside
the development repository, based on the PR's upstream base. Independent pending
console/container edits were not included.
Local Windows verification used managed Rust
1.97.1-ms-20260901.3:The eleven new adapter regressions exercise nested Grid/Flexbox, fractional
tracks and their automatic versus zero minimums, flex growth/shrinkage, integer
rounding, legacy insets, tiny/zero viewports, floating-node exclusion, legacy
table/scrollarea behavior, and style ownership. A CSS row nested inside a legacy
block also has a regression: its CSS intrinsic size must not be overwritten by
the old vertical-stack measurement.
Two additional tests call the application's actual draw path. They cover no
document, empty and long documents, hidden/disabled Search, Search and Replace,
widths 1/2/80, shrinking/growing heights 1-8, 24, 80, and 32767, and retained
keyboard focus after a tiny viewport is restored.
These are geometry and interaction tests, not an external-terminal end-to-end
test, a reproduced-crash claim, or a claim of browser-wide CSS conformance.
Upstream CI run 35231717154
passed on both Windows and Ubuntu at
6f675bd: formatting, all-feature/all-targettests, and workspace Clippy with warnings denied. The focus regression respects
the existing platform policy: Unix documents append a final newline; Windows
documents do not do so by default.
Suggested review order
main.rsanddraw_editor.rs.tui.rs.tui/css_layout.rs.The previous fill-height implementation is superseded, not retained alongside
this one. Acceptance of this layout slice does not imply acceptance of any
feature from the separate console/provider experiment.