I don't think it matters; commit 2da5b0b14682f5522b84116b3e6a6688de3c7423
Add some tabs, close some tabs. Might have to fiddle about with focus or something. It doesn't always happen straight away.
It doesn't crash.
It crashes, losing all your tabs.
The crash is here, on line 93 of Microsoft.Terminal.TerminalControl.h in Title():
check_hresult(WINRT_SHIM(Microsoft::Terminal::TerminalControl::ITermControl)->get_Title(&value));
The calling code is at line 1037..1041 of App.cpp in GetTitle():
try
{
return _GetFocusedControl().Title();
}
CATCH_LOG();
And the caller of that was _OnTabSelectionChanged().
Unfortunately it is not a thrown exception but an access violation, so the C++ exception handling doesn't help.
Inside _GetFocusedControl(), it would be possible for _GetFocusedTabIndex() to return -1, but it doesn't seem to be in this case. Also it could conceivably return >= _tabs.size() but it isn't doing that either. The problem is that _GetFocusedTerminalControl() returns nullptr, which according to its documentation is a reasonable thing to do.
I changed the code inside the try{} to:
auto focusedControl = _GetFocusedControl();
if (focusedControl)
return focusedControl.Title();
This seems to stop it crashing. But there are other places where _GetFocusedControl() is called without checking for a null result. So perhaps another tab should be considered focused, or something.
Also if you create shells quickly, some of them end up with no title. I think that's related, because if you click on one of those tabs, the window title (can be seen by hovering over the app's icon in the taskbar) is "Windows Terminal" which is GetTitle()s default.
Found better repro steps:
Most helpful comment
Found better repro steps: