Skip to content

Prevent panes from shrinking below 2x2 cells - #20564

Merged
Dustin L. Howett (DHowett) merged 3 commits into
microsoft:mainfrom
zhangxaochen:dev/min-pane-2x2
Sep 12, 2026
Merged

Prevent panes from shrinking below 2x2 cells#20564
Dustin L. Howett (DHowett) merged 3 commits into
microsoft:mainfrom
zhangxaochen:dev/min-pane-2x2

Conversation

@zhangxaochen

@zhangxaochen zhangxaochen commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

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

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

Copy link
Copy Markdown
Contributor 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
@lhecker

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command.

@lhecker

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command.

@lhecker

Copy link
Copy Markdown
Member

......wat?

Anyway, you (we?) must merge main into this branch.

@zhangxaochen

Copy link
Copy Markdown
Contributor Author

Merged main into this branch to clear the conflict. Launch.xaml kept the new SettingsExpander layout and the 2-cell minimum.

@lhecker

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
1 pipeline(s) were filtered out due to trigger conditions.

@zhangxaochen

Copy link
Copy Markdown
Contributor Author

Leonard Hecker (@lhecker) Dustin L. Howett (@DHowett) CI is green and this has an approval. Ready to merge whenever you have a moment.

Comment thread src/inc/DefaultSettings.h
constexpr int DEFAULT_COLS = 120;

// VT theoretical minimum (DECSTBM / DECSLRM). A 1-cell viewport can hang
// TextBuffer::Reflow on a wide glyph (GH#19996).

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.

(Leonard Hecker (@lhecker) why would we merge this instead of just fixing the root cause?)

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.

If we fix the root cause, the wide glyphs get dropped entirely.
Any ideal fix would fix the root cause and also this.

@DHowett

Copy link
Copy Markdown
Member
image

I will not merge this pull request with the "cursor agent" attribution in the commit history. Please rebase to remove cursor from your history and indicate to us that you take full ownership of the code herein authored.

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.

as noted

@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 Sep 11, 2026
zhangxaochen and others added 3 commits September 12, 2026 00:12
A 1-column reflow of a wide glyph hangs in TextBuffer::Reflow (GH#19996).
GetProposedDimensions and UserResize still allowed a 1-cell
viewport, which is the GH#19996 hang path.
@zhangxaochen

Copy link
Copy Markdown
Contributor Author

Removed the Cursor trailer and rebased onto latest main. I take full ownership of the changes in this PR.

On the root-cause question: this PR is the first cut from #19996 (stop 1-cell resize). TextBuffer::Reflow is still separate.

@microsoft-github-policy-service microsoft-github-policy-service Bot removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Sep 11, 2026
@DHowett

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
1 pipeline(s) were filtered out due to trigger conditions.

@DHowett
Dustin L. Howett (DHowett) merged commit e7a68df into microsoft:main Sep 12, 2026
14 of 16 checks passed
@zhangxaochen
zhangxaochen deleted the dev/min-pane-2x2 branch September 12, 2026 11:46
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

3 participants