Skip to content

Introduce native CSS-style Grid for the editor layout - #950

Open
Michael Greene (mgreenegit) wants to merge 1 commit into
microsoft:mainfrom
mgreenegit:fix/editor-height-small-viewports
Open

Michael Greene (mgreenegit) wants to merge 1 commit into
microsoft:mainfrom
mgreenegit:fix/editor-height-small-viewports

Conversation

@mgreenegit

@mgreenegit Michael Greene (mgreenegit) commented Sep 11, 2026 •

Copy link
Copy Markdown
Member

Summary

Introduce a dependency-free, CSS-style Grid primitive and use it for the viewport/editor layout, replacing the editor's manual height subtraction. This is a first replacement slice, not an enhancement to the legacy table engine.

This pull request was drafted by a large language model (LLM).

Scope

  • Explicit display: grid, independent row/column templates, and flat row-major child placement.
  • Intrinsic Auto tracks, fixed terminal-cell sizes, and integer fractional tracks. Fraction(n) means minmax(0, nfr), so editor content can shrink inside its viewport.
  • One allocator for both axes. Auto tracks share unused space when no positive fractions exist; overflow is clipped.
  • The existing implicit root fills the viewport. The editor reserves intrinsic space for chrome and Search/Replace, leaving the rest to the document.
  • No dependencies, production-code relocation, or console/provider changes.

The equal-pane declaration is:

ctx.attr_display(Display::Grid);
ctx.attr_grid_template_columns(&[GridTrack::Fraction(1)]);
ctx.attr_grid_template_rows(&[
    GridTrack::Fixed(1),
    GridTrack::Fraction(1),
    GridTrack::Fraction(1),
    GridTrack::Fixed(1),
]);

Templates are typed Rust, not parsed stylesheets. Intrinsic measurement remains Edit's existing model, not browser min/max-content sizing. This does not claim full CSS Grid compliance.

Migration boundary

Legacy tables, their APIs, and menu/dialog declarations remain unchanged. Their layout path temporarily coexists with Grid; this PR does not claim to remove it. Shared collapsed-rectangle handling keeps zero-sized grid descendants valid.

The follow-up #961 unifies the engine using boxed column subgrids with preserved row focus, highlighting, and hitboxes. #962 then migrates the remaining callers and removes the table API without changing that shared engine. These interaction and migration contracts are intentionally outside this first main-view slice.

Review/merge order: #950 -> #961 -> #962. Both follow-ups link exact incremental comparisons because their full Files changed tabs include the unmerged prerequisites.

Each PR contains one commit. The follow-ups link content-identical review snapshots to isolate their incremental scope.

Review and validation

Five files: 254 changed production/documentation/registration lines, plus 343 test lines (597 total, down from 604). A private item-placement helper adds three lines versus the previous revision but reduces replacement in #961; the TUI-only pass removes 16 incremental changed lines across the series. Collapse/override fixtures share setup; alignment cases reuse a TUI.

Latest local validation: six Grid tests and two application layout tests pass, along with formatting, pre-commit workspace Clippy, and scoped structural checks. Test files are unchanged by the TUI-only pass.

Final-head Windows/Ubuntu CI and CodeQL pass at a23b7ac.

Regressions cover both-axis placement, intrinsic and fractional sizing, rounding, nested/padded and collapsed grids, floats, constrained alignment, repeated viewport resizing, editor typing/scrolling/search focus, and legacy menu highlighting and trailing-edge mouse activation under a grid ancestor. The shared interaction scenario checks typing after resize, closing Search, and closing a menu, for both empty and long documents.

An independent read-only review found no concrete correctness blocker. Its requested grid/legacy-menu interaction regression and subset documentation are included.

@mgreenegit
Michael Greene (mgreenegit) marked this pull request as ready for review September 11, 2026 21:55
@mgreenegit Michael Greene (mgreenegit) changed the title Clamp editor intrinsic height in small viewports Let layout determine the editor's remaining height Sep 16, 2026

@lhecker Leonard Hecker (lhecker) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/

@mgreenegit
Michael Greene (mgreenegit) force-pushed the fix/editor-height-small-viewports branch from 53b2842 to 9321dee Compare September 17, 2026 14:00
@mgreenegit Michael Greene (mgreenegit) changed the title Let layout determine the editor's remaining height Use CSS Grid and Flexbox for editor layout Sep 17, 2026
@mgreenegit
Michael Greene (mgreenegit) marked this pull request as draft September 17, 2026 15:04
@mgreenegit
Michael Greene (mgreenegit) force-pushed the fix/editor-height-small-viewports branch from 6f675bd to 3c158ef Compare September 21, 2026 17:08
@mgreenegit Michael Greene (mgreenegit) changed the title Use CSS Grid and Flexbox for editor layout Extend native table layout with row and column tracks Sep 21, 2026
@mgreenegit
Michael Greene (mgreenegit) force-pushed the fix/editor-height-small-viewports branch 3 times, most recently from fe7c700 to b052ba2 Compare September 21, 2026 19:14
@mgreenegit Michael Greene (mgreenegit) changed the title Extend native table layout with row and column tracks Introduce native CSS-style Grid for the editor layout Sep 21, 2026
@mgreenegit
Michael Greene (mgreenegit) marked this pull request as ready for review September 21, 2026 22:08
Michael Greene (mgreenegit) added a commit to mgreenegit/edit that referenced this pull request Sep 22, 2026
Include the Grid prerequisite from microsoft#950 and route existing table declarations through the durable shared engine. Preserve interactive boxed rows, intrinsic sizing, gaps, and navigation with generic Grid properties. Application caller migration remains in microsoft#962.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Michael Greene (mgreenegit) added a commit to mgreenegit/edit that referenced this pull request Sep 22, 2026
Include the Grid prerequisites from microsoft#950 and microsoft#961, migrate all remaining table callers to explicit Grid declarations, and remove the compatibility API. Preserve shared engine algorithms and generic regressions from the second slice while checking dialog and file-picker focus restoration.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Michael Greene (mgreenegit) added a commit to mgreenegit/edit that referenced this pull request Sep 22, 2026
Add typed row and column tracks with shared sizing and bounded placement, and adopt Grid for the viewport and editor. Cover layout geometry, resizing, focus, and existing menu interaction without changing legacy table callers. First slice of microsoft#950, microsoft#961, and microsoft#962.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mgreenegit
Michael Greene (mgreenegit) force-pushed the fix/editor-height-small-viewports branch 2 times, most recently from 6ce4461 to 0540de4 Compare September 22, 2026 15:18
Add typed tracks and bounded placement, adopting Grid for the editor viewport. Keep item placement in a private helper extended by the subsequent table-unification slice, preserving constrained alignment and interaction regressions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mgreenegit
Michael Greene (mgreenegit) force-pushed the fix/editor-height-small-viewports branch from 0540de4 to a23b7ac Compare September 22, 2026 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants