Skip to content

Prevent panes from shrinking below 2x2 cells - #20564

Open
zhangxaochen wants to merge 2 commits into
microsoft:mainfrom
zhangxaochen:dev/min-pane-2x2
Open

Prevent panes from shrinking below 2x2 cells#20564
zhangxaochen wants to merge 2 commits into
microsoft:mainfrom
zhangxaochen:dev/min-pane-2x2

Conversation

@zhangxaochen

@zhangxaochen zhangxaochen commented Aug 20, 2026

Copy link
Copy Markdown

Summary of the Pull Request

Raise the visible terminal minimum from 1×1 cells to 2×2 cells so a pane or window can no longer reach a 1-column viewport (keyboard, mouse, split-pane, wt --size, initialCols/initialRows, or VT resize).

This is a mitigation. It closes the hang for users, but does not fix TextBuffer::Reflow when a 2-column glyph is copied into a 1-column row. TextBuffer still accepts a 1-column size; Cascadia no longer asks for one.

Closes #19996.

References and Relevant Issues

Detailed Description of the Pull Request / Additional comments

Shared floor is MINIMUM_VISIBLE_CELLS (2) in DefaultSettings.h.

  • TermControl::MinimumSize / GetProposedDimensions / GetNewDimensions
  • ControlCore create and _refreshSizeUnderLock (the UserResize hang path)
  • Terminal::Create / CreateFromSettings / UserResize
  • HwndTerminal
  • settings initialCols / initialRows clamp and the Launch page minimum

Pane::_GetMinSize / _ClampSplitPosition / _CalcSnappedDimension / PreCalculateCanSplit still consume MinimumSize(), so pane resize stays covered.

Left alone on purpose:

  • TextBuffer / conhost 1×1 — remaining Reflow root-cause
  • ConptyConnection / AppHost max(..., 1) — PTY size and pixel clamps, not cell counts

ASCII-only panes already survived a 1-cell clamp. Wide glyphs (CJK, emoji, starship prompts) did not.

Validation Steps Performed

  • Confirmed the hang on unpatched Dev (WindowsTerminalDev) and Store 1.24.11911 with echo 音楽🎵测试 in view, then shrink the left pane to the stop.
  • Live dump of hung Dev PID 27880: UI thread in TextBuffer::ReflowTerminal::UserResizeControlCore::_refreshSizeUnderLockTermControl::_SwapChainSizeChanged. Render thread blocked on the same console lock.
  • ASCII control (echo hello) stopped at minimum width and stayed responsive.
  • After this change, the same wide-glyph shrink should stop at ~2 columns and stay alive. Needs a rebuilt Dev package to confirm on this machine.

PR Checklist

A 1-column reflow of a wide glyph hangs in TextBuffer::Reflow (GH#19996).

Co-authored-by: Cursor <cursoragent@cursor.com>
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@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.

This misses GetProposedDimensions and its std::max. I'm not sure if there are more places.

@microsoft-github-policy-service microsoft-github-policy-service Bot added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Aug 20, 2026
GetProposedDimensions and UserResize still allowed a 1-cell
viewport, which is the GH#19996 hang path.
@zhangxaochen

Copy link
Copy Markdown
Author

Leonard Hecker (@lhecker) Thanks — I missed those.

GetProposedDimensions now floors at MINIMUM_VISIBLE_CELLS (2), same as MinimumSize. I also audited the other cell-count floors:

  • GetNewDimensions (VT / window-size requests)
  • ControlCore create + _refreshSizeUnderLock (the UserResize hang path)
  • Terminal::Create / CreateFromSettings / UserResize
  • HwndTerminal
  • settings initialCols / initialRows clamp + the Launch page minimum

Left alone on purpose:

  • TextBuffer / conhost 1×1 — still the remaining Reflow root-cause
  • ConptyConnection / AppHost max(..., 1) — PTY size and pixel clamps, not cell counts

@microsoft-github-policy-service microsoft-github-policy-service Bot added Needs-Attention The core contributors need to come back around and look at this ASAP. and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs-Attention The core contributors need to come back around and look at this ASAP.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Terminal hangs when resizing pane to minimum width with Alt+Shift+Left

2 participants