Let layout determine the editor's remaining height - #950
Open
Michael Greene (mgreenegit) wants to merge 3 commits into
Open
Michael Greene (mgreenegit) wants to merge 3 commits into
Michael Greene (mgreenegit) wants to merge 3 commits into
Conversation
When the viewport is shorter than the rows reserved for editor chrome or search, draw_editor currently supplies a negative intrinsic height. Clamp the available text height to zero, preserving existing heights when space is sufficient. Keep the calculation private and cover hidden/disabled/search/replace modes at zero, boundary, normal, and maximum supported heights, including shrinking and growing sequences. Provenance: extract the nonnegative height calculation used in console-exploration-0 at 1d21f16b14998d643ff79e4ce36bb519e3d1fd7b (also retained in combined-exploration-0 at a0f14a4). This is an independently useful console prerequisite, not the embedded console feature. No providers, AI, process launch, dependencies, settings, public API, or keyboard behavior are added. Validation: the focused regression failed before the clamp (height 1, reserved 2 yielded -1). cargo test --locked --package edit --bin edit passes all 3 tests afterward on Windows with msrustup ms-prod rustc 1.97.1. Candidate structural gate accepted. Review/rollback boundary: this one file; revert this commit independently. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> (cherry picked from commit af11d6bd14bbc30b786173772b6d2d648150c518)
Michael Greene (mgreenegit)
marked this pull request as ready for review
September 11, 2026 21:55
Resolve the adjacent TODO with an opt-in fill-height attribute for vertical blocks. Reserve measured sibling heights and decorations, clamp remaining content height to zero, and distribute it between filling children. Migrate the editor and empty placeholder off fixed UI row reservations. Replace the initial arithmetic-only regression with actual layout geometry coverage for small/resized viewports, empty and long text buffers, floating nodes, fixed siblings, shared remainder and nested decorations. Preserve existing intrinsic measurement and specialized table/scrollarea layout behavior. Validated 47 library tests and 2 binary tests, warning-denying Clippy, and the focused structural change gate. No console implementation is included. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Apply the exact whitespace-only change reported by both Linux and Windows Check formatting jobs. The four targeted layout regressions pass. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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/
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
draw_editorcurrently determines the text area's height by subtracting fixed UI reservations from the viewport: 2 rows with search hidden/disabled, 4 with Search, and 5 with Replace. The adjacent TODO identifies the underlying limitation:This duplicates information that is already present in the UI tree. The editor must know how much space its siblings consume, and that accounting must stay synchronized with what is actually drawn.
It also allows a negative intrinsic height in short viewports: a three-row viewport with Replace active requests
3 - 5 = -2. The intrinsic-size setter stores that value, and the layout engine uses it in parent sizing and sibling positioning.Change
Add one opt-in layout attribute,
Context::attr_fill_height, and use it for the editor's text area (or its empty placeholder when no document is open).The existing vertical-block layout now:
The editor is the only production caller added here. With one filling child, its content height is simply:
Menu, search and status rows are accounted for from the current tree, including siblings drawn after the editor. Floating nodes are outside that stack and do not consume its height.
This removes the editor's hard-coded row subtraction and resolves the adjacent TODO. It also preserves the small-viewport safety goal: insufficient space gives the unbordered editor zero height, not a negative requested size.
Why this is useful
draw_editor.This is a focused vertical-height capability, not a general flexbox system: no weights, shrink priorities, new layout modes or horizontal sizing changes. Unmarked children keep their existing intrinsic-height allocation. Intrinsic measurement and the specialized table/scrollarea layout rules are unchanged.
Scope and review
Three files: the editor call site, the TUI attribute/allocation implementation, and focused TUI tests. No dependencies, settings, commands or platform-specific code are added.
This revision supersedes the PR's initial caller-side clamp and arithmetic-only test with the layout-based fix and geometry tests. It deliberately expands the original one-file scope to address the existing TODO; the original commit remains in the history.
It does not guarantee that all controls remain visible or usable in arbitrarily short terminals, and it does not change existing clipping or overflow policy.
Validation
Four regressions inspect actual node rectangles after the TUI layout pass:
COORD_TYPE_SAFE_MAX; those geometry bounds are outside the terminal Resize event contract.Before the allocator change, the initial three layout regressions failed. For example, an eight-row viewport left the empty editor at zero rows instead of the expected six; the nested case also displaced the trailing status row. All four final regressions pass.
Local verification on Windows with Rust 1.97.1:
These exercise the real layout engine and text-area widgets, but are not end-to-end tests of the running editor or evidence of a reproduced crash. Cross-platform validation remains for upstream CI; the local results are not a claim that CI has passed.
Origin
The boundary case arose during a separate console experiment, but this change applies independently to the existing editor. No console implementation, providers or AI code is included, and acceptance does not require agreement on those features.