microsoft / terminal

The new Windows Terminal and the original Windows console host, all in the same place!
MIT License
95.89k stars 8.34k forks source link

Crash when attempting to split pane with insufficient space available #2401

Closed richardszalay closed 5 years ago

richardszalay commented 5 years ago

Environment

Windows build number: Microsoft Windows [Version 10.0.18362.175]
Windows Terminal version (if applicable):0.3.2171.0

Steps to reproduce

  1. Map a key binding to splitHorizontal
  2. Invoke the splitHorizontal key binding beyond the point where space is available for the split (~6-7 times)

NOTE: It also happens when splitting vertically but it appears to allow more before crashing.

Expected behavior

Worth discussing, but I'm guessing it would simply reject the command and perform a system beep (or some other indication of the failure)

Actual behavior

Application crash

richardszalay commented 5 years ago

I've confirmed that the root cause of the error is that splitting small panes results in a width/height of 0, which causes the DxRenderer to fail when creating the device resources.

I'd like to PR this if you don't mind. Here's my proposed implementation, but I'm happy to PR it as a spec if you think the issue warrants it:

App::_SplitPane will call 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?

I'll follow the same naming conventions that already exist, so: Tab::CanAddHorizontalSplit -> Pane::CanSplitHorizontal ->Pane::_CanSplit. The public pane methods will handle leaf/child the same as the current Split methods.

_CanSplit will reuse existing logic to determine the split, including _root.GetActualWidth/height, Pane::_GetMinSize, and the Half constant.

richardszalay commented 5 years ago

If you're happy with my proposed design and don't think it needs a beep, I've submitted a PR.

zadjii-msft commented 5 years ago

Yea I definitely don't think we need a beep currently. We don't beep for anything else quite yet, so we could always add a (optional) beep here later when we add beeps to the rest of the app.

Good work with the PR!

ghost commented 5 years ago

:tada:This issue was addressed in #2450, which has now been successfully released as Windows Terminal Preview v0.4.2382.0.:tada:

Handy links: