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

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/2450
Author: @richardszalay
Created: 8/16/2019
Status: Merged
Merged: 8/20/2019
Merged by: @DHowett-MSFT

Base: masterHead: 2401-minimum-split-pane-size


📝 Commits (1)

📊 Changes

5 files changed (+118 additions, -2 deletions)

View changed files

📝 src/cascadia/TerminalApp/App.cpp (+10 -2)
📝 src/cascadia/TerminalApp/Pane.cpp (+84 -0)
📝 src/cascadia/TerminalApp/Pane.h (+4 -0)
📝 src/cascadia/TerminalApp/Tab.cpp (+18 -0)
📝 src/cascadia/TerminalApp/Tab.h (+2 -0)

📄 Description

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.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/2450 **Author:** [@richardszalay](https://github.com/richardszalay) **Created:** 8/16/2019 **Status:** ✅ Merged **Merged:** 8/20/2019 **Merged by:** [@DHowett-MSFT](https://github.com/DHowett-MSFT) **Base:** `master` ← **Head:** `2401-minimum-split-pane-size` --- ### 📝 Commits (1) - [`8c78574`](https://github.com/microsoft/terminal/commit/8c78574141eb9100a46fe6afe8ecca9a45010a34) Prevent splitting panes into 0 width/height #2401 ### 📊 Changes **5 files changed** (+118 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `src/cascadia/TerminalApp/App.cpp` (+10 -2) 📝 `src/cascadia/TerminalApp/Pane.cpp` (+84 -0) 📝 `src/cascadia/TerminalApp/Pane.h` (+4 -0) 📝 `src/cascadia/TerminalApp/Tab.cpp` (+18 -0) 📝 `src/cascadia/TerminalApp/Tab.h` (+2 -0) </details> ### 📄 Description 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:06:12 +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#24934