[PR #2450] Prevent splitting panes into 0 width/height #2401 #24939

Open
opened 2026-01-31 09:06:14 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/2450

State: closed
Merged: Yes


Fixes a crash that can occur when splitting pane that was so small that the target panes would have a width/height of 0, causing DxRenderer to fail when creating the device resources.

This PR prevents both the call to App::AddHorizontal/VerticalSplit and the creation of the TermControl if the split would fail.

Summary of the Pull Request

References

PR Checklist

  • Closes Bug Report - Terminal crashes if we open bash inside a cmd shell (#2401)
  • CLA signed. If not, go over here and sign the CLA
  • Tests added/passed (there are no tests for this part of WT)
  • Requires documentation to be updated
  • I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #2401

Detailed Description of the Pull Request / Additional comments

App::_SplitPane calls focusedTab->CanAddHorizontalSplit/CanAddHorizontalSplit before it initializes the TermControl to avoid having to deal with the cleanup. If a split cannot occur, it will simply return.

Question: Should we beep or something here?

It then follows the same naming/flow style as the split operation, so: Tab::CanAddHorizontalSplit -> Pane::CanSplitHorizontal ->Pane::_CanSplit. The public pane methods will handle leaf/child the same as the current Split methods.

_CanSplit reuses existing logic like _root.GetActualWidth/Height, Pane::_GetMinSize, and the Half constant.

Validation Steps Performed

  1. Open a new tab
  2. Attempt to split horizontally/vertically more than 6-8 times

Success: Pane will will eventually stop splitting rather than crashing the process.

**Original Pull Request:** https://github.com/microsoft/terminal/pull/2450 **State:** closed **Merged:** Yes --- Fixes a crash that can occur when splitting pane that was so small that the target panes would have a width/height of 0, causing DxRenderer to fail when creating the device resources. This PR prevents both the call to `App::AddHorizontal/VerticalSplit` and the creation of the `TermControl` if the split would fail. ## Summary of the Pull Request ## References ## PR Checklist * [x] Closes #2401 * [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA * [ ] Tests added/passed (_there are no tests for this part of WT_) * [ ] Requires documentation to be updated * [ ] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #2401 ## Detailed Description of the Pull Request / Additional comments `App::_SplitPane` calls `focusedTab->CanAddHorizontalSplit/CanAddHorizontalSplit` before it initializes the `TermControl` to avoid having to deal with the cleanup. If a split cannot occur, it will simply return. **Question: Should we beep or something here?** It then follows the same naming/flow style as the split operation, so: `Tab::CanAddHorizontalSplit -> Pane::CanSplitHorizontal ->Pane::_CanSplit`. The public pane methods will handle leaf/child the same as the current Split methods. `_CanSplit` reuses existing logic like `_root.GetActualWidth/Height`, `Pane::_GetMinSize`, and the `Half` constant. ## Validation Steps Performed 1. Open a new tab 2. Attempt to split horizontally/vertically more than 6-8 times Success: Pane will will eventually stop splitting rather than crashing the process.
claunia added the pull-request label 2026-01-31 09:06:14 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#24939