terminal/src/cascadia/TerminalApp
Mike Griese b3fa88eaed
Process actions sync. on startup; don't dupe nonexistent profile (#5090)
This PR has evolved to encapsulate two related fixes that I can't really
untie anymore.

#2455 - Duplicating a tab that doesn't exist anymore

This was the bug I was originally fixing in #4429. 

When the user tries to `duplicateTab` with a profile that doesn't exist
anymore (like might happen after a settings reload), don't crash.

As I was going about adding tests for this, got blocked by the fact that
the Terminal couldn't open _any_ panes while the `TerminalPage` was size
0x0. This had two theoretical solutions: 

* Fake the `TerminalPage` into thinking it had a real size in the test -
  probably possible, though I'm unsure how it would work in practice.
* Change `Pane`s to not require an `ActualWidth`, `ActualHeight` on
  initialization. 

Fortuately, the second option was something else that was already on my
backlog of bugs. 

#4618 - `wt` command-line can't consistently parse more than one arg

Presently, the Terminal just arbitrarily dispatches a bunch of handlers
to try and handle all the commands provided on the commandline. That's
lead to a bunch of reports that not all the commands will always get
executed, nor will they all get executed in the same order. 

This PR also changes the `TerminalPage` to be able to dispatch all the
commands sequentially, all at once in the startup. No longer will there
be a hot second where the commands seem to execute themselves in from of
the user - they'll all happen behind the scenes on startup. 

This involved a couple other changes areound the `TerminalPage`
* I had to make sure that panes could be opened at a 0x0 size. Now they
  use a star sizing based off the percentage of the parent they're
  supposed to consume, so that when the parent _does_ get laid out,
  they'll take the appropriate size of that parent.
* I had to do some math ahead of time to try and calculate what a
  `SplitState::Automatic` would be evaluated as, despite the fact that
  we don't actually know how big the pane will be. 
* I had to ensure that `focus-tab` commands appropriately mark a single
  tab as focused while we're in startup, without roundtripping to the
  Dispatcher thread and back

## References

#4429 - the original PR for #2455
#5047 - a follow-up task from discussion in #4429
#4953 - a PR for making panes use star sizing, which was immensly
        helpful for this PR.

## Detailed Description of the Pull Request / Additional comments

`CascadiaSettings::BuildSettings` can throw if the GUID doesn't exist.
This wraps those calls up with a try/catch.

It also adds a couple tests - a few `SettingsTests` for try/catching
this state. It also adds a XAML-y test in `TabTests` that creates a
`TerminalPage` and then performs som UI-like actions on it. This test
required a minor change to how we generate the new tab dropdown - in the
tests, `Application::Current()` is _not_ a `TerminalApp::App`, so it
doesn't have a `Logic()` to query. So wrap that in a try/catch as well.

While working on these tests, I found that we'd crash pretty agressively
for mysterious reasons if the TestHostApp became focused while the test
was running. This was due to a call in
`TSFInputControl::NotifyFocusEnter` that would callback to
`TSFInputControl::_layoutRequested`, which would crash on setting the
`MaxSize` of the canvas to a negative value. This PR includes a hotfix
for that bug as well. 

## Validation Steps Performed

* Manual testing with a _lot_ of commands in a commandline
* run the tests
* Team tested in selfhost

Closes #2455
Closes #4618
2020-03-25 17:03:32 -07:00
..
lib Prepare for automated localization (#5119) 2020-03-25 21:06:59 +00:00
Resources/en-US Prepare for automated localization (#5119) 2020-03-25 21:06:59 +00:00
ActionAndArgs.cpp Add support for arbitrary args in keybindings (#3391) 2019-11-14 16:23:40 -06:00
ActionAndArgs.h Add support for arbitrary args in keybindings (#3391) 2019-11-14 16:23:40 -06:00
ActionArgs.cpp Add support for new panes with specifc profiles and other settings overrides (#3825) 2019-12-09 13:02:29 +00:00
ActionArgs.h Add a splitPane option to duplicate current profile (#4683) 2020-03-06 23:15:45 +00:00
ActionArgs.idl Add a splitPane option to duplicate current profile (#4683) 2020-03-06 23:15:45 +00:00
App.base.h Apply a GDI region to the top level Island window to allow dragging with a single Island (#929) 2019-06-25 13:06:11 -07:00
App.cpp Create Telnet connection type and default loopback profile for… (#3858) 2019-12-09 11:07:08 -08:00
App.h Break everything out of App except Xaml platform init (#3465) 2019-11-07 13:10:58 -08:00
App.idl Break everything out of App except Xaml platform init (#3465) 2019-11-07 13:10:58 -08:00
App.xaml Round and style buttons on close all tabs dialog (#4401) 2020-01-30 15:51:43 -08:00
AppActionHandlers.cpp Add a splitPane option to duplicate current profile (#4683) 2020-03-06 23:15:45 +00:00
AppCommandlineArgs.cpp ci: run spell check in CI, fix remaining issues (#4799) 2020-03-25 11:02:53 -07:00
AppCommandlineArgs.h Configure CLI11 to stuff all unknown positionals into the cmdli… (#4388) 2020-01-29 13:01:05 -08:00
AppKeyBindings.cpp Encapsulate dispatching ShortcutActions in it's own class (#3658) 2019-11-27 15:51:38 -06:00
AppKeyBindings.h Add warning messages for bad keybindings (#4746) 2020-03-05 21:06:58 +00:00
AppKeyBindings.idl Encapsulate dispatching ShortcutActions in it's own class (#3658) 2019-11-27 15:51:38 -06:00
AppKeyBindingsSerialization.cpp ci: run spell check in CI, fix remaining issues (#4799) 2020-03-25 11:02:53 -07:00
AppLogic.cpp ci: run spell check in CI, fix remaining issues (#4799) 2020-03-25 11:02:53 -07:00
AppLogic.h Prevent tab reordering while elevated (#4874) 2020-03-11 15:52:09 +00:00
AppLogic.idl Prevent tab reordering while elevated (#4874) 2020-03-11 15:52:09 +00:00
AzureCloudShellGenerator.cpp Implement ConnectionState and closeOnExit=graceful/always/never (#3623) 2019-11-25 14:22:29 -08:00
AzureCloudShellGenerator.h Add Dynamic Profile Generators (#2603) 2019-09-16 13:34:27 -07:00
CascadiaSettings.cpp Add warning messages for bad keybindings (#4746) 2020-03-05 21:06:58 +00:00
CascadiaSettings.h Gracefully handle json data with the wrong value types (#4961) 2020-03-20 20:35:51 +00:00
CascadiaSettingsSerialization.cpp ci: run spell check in CI, fix remaining issues (#4799) 2020-03-25 11:02:53 -07:00
ColorScheme.cpp Add cursorColor to color scheme (#4651) 2020-03-17 20:11:03 +00:00
ColorScheme.h Add cursorColor to color scheme (#4651) 2020-03-17 20:11:03 +00:00
Commandline.cpp Add support for commandline args to wt.exe (#4023) 2020-01-27 15:34:12 +00:00
Commandline.h Add support for commandline args to wt.exe (#4023) 2020-01-27 15:34:12 +00:00
DefaultProfileUtils.cpp Add Dynamic Profile Generators (#2603) 2019-09-16 13:34:27 -07:00
DefaultProfileUtils.h Add Dynamic Profile Generators (#2603) 2019-09-16 13:34:27 -07:00
defaults-universal.json Set Cascadia Code as default font (#5121) 2020-03-25 21:52:34 +00:00
defaults.json Set Cascadia Code as default font (#5121) 2020-03-25 21:52:34 +00:00
FixVisualStudioBug.targets Fix a bunch of spelling errors across the project (#4295) 2020-02-10 20:40:01 +00:00
GlobalAppSettings.cpp Gracefully handle json data with the wrong value types (#4961) 2020-03-20 20:35:51 +00:00
GlobalAppSettings.h Add warning messages for bad keybindings (#4746) 2020-03-05 21:06:58 +00:00
IDynamicProfileGenerator.h Add Dynamic Profile Generators (#2603) 2019-09-16 13:34:27 -07:00
IF7Listener.idl Tunnel F7 keypresses directly into special handlers in TermControl (#4807) 2020-03-05 20:35:46 +00:00
init.cpp Introduce a WinRT utils library and "checked resources" (#3350) 2019-11-01 15:47:05 -07:00
JsonUtils.cpp Gracefully handle json data with the wrong value types (#4961) 2020-03-20 20:35:51 +00:00
JsonUtils.h Gracefully handle json data with the wrong value types (#4961) 2020-03-20 20:35:51 +00:00
KeyChordSerialization.cpp Fix a bunch of spelling errors across the project (#4295) 2020-02-10 20:40:01 +00:00
KeyChordSerialization.h Support remapping keybindings (#748) 2019-05-21 09:26:04 -05:00
LegacyProfileGeneratorNamespaces.h Create Telnet connection type and default loopback profile for… (#3858) 2019-12-09 11:07:08 -08:00
MinMaxCloseControl.cpp Unify and clean up the common build properties (#3429) 2019-11-05 14:29:11 -08:00
MinMaxCloseControl.h Propagate window style changes to the titlebar and minmax (#3025) 2019-10-02 10:27:07 -07:00
MinMaxCloseControl.idl Propagate window style changes to the titlebar and minmax (#3025) 2019-10-02 10:27:07 -07:00
MinMaxCloseControl.xaml Polish AutomationProperties and UIA Tree Navigation (#4805) 2020-03-05 22:32:46 +00:00
packages.config deps: upgrade CppWinRT to 2.0.200316.3, gsl to v2.1.0 (#4536) 2020-03-23 17:15:24 +00:00
Pane.cpp Process actions sync. on startup; don't dupe nonexistent profile (#5090) 2020-03-25 17:03:32 -07:00
Pane.h Process actions sync. on startup; don't dupe nonexistent profile (#5090) 2020-03-25 17:03:32 -07:00
Pane.LayoutSizeNode.cpp Snap to character grid when resizing window (#3181) 2020-01-08 13:19:23 -08:00
pch.cpp Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
pch.h Refactor TerminalApp and Add Tests for Xaml Content (#1164) 2019-07-15 14:27:56 -05:00
PowershellCoreProfileGenerator.cpp ci: run spell check in CI, fix remaining issues (#4799) 2020-03-25 11:02:53 -07:00
PowershellCoreProfileGenerator.h Collect all known PowerShell Core installations for dynamic profiles (#4273) 2020-01-31 04:17:21 +00:00
Profile.cpp Gracefully handle json data with the wrong value types (#4961) 2020-03-20 20:35:51 +00:00
Profile.h Add cursorColor to color scheme (#4651) 2020-03-17 20:11:03 +00:00
ShortcutActionDispatch.cpp Search - add search box control and implement search experience (#3590) 2019-12-17 15:52:37 +00:00
ShortcutActionDispatch.h Search - add search box control and implement search experience (#3590) 2019-12-17 15:52:37 +00:00
ShortcutActionDispatch.idl Search - add search box control and implement search experience (#3590) 2019-12-17 15:52:37 +00:00
Tab.cpp Process actions sync. on startup; don't dupe nonexistent profile (#5090) 2020-03-25 17:03:32 -07:00
Tab.h Process actions sync. on startup; don't dupe nonexistent profile (#5090) 2020-03-25 17:03:32 -07:00
Tab.idl Convert Tab to a WinRT type (#4350) 2020-02-04 21:51:11 +00:00
TabRowControl.cpp Upgrade to Microsoft.UI.Xaml 2.2 (#3027) 2019-10-14 22:41:43 -07:00
TabRowControl.h Upgrade to Microsoft.UI.Xaml 2.2 (#3027) 2019-10-14 22:41:43 -07:00
TabRowControl.idl Upgrade to Microsoft.UI.Xaml 2.2 (#3027) 2019-10-14 22:41:43 -07:00
TabRowControl.xaml Polish AutomationProperties and UIA Tree Navigation (#4805) 2020-03-05 22:32:46 +00:00
TelnetGenerator.h Create Telnet connection type and default loopback profile for… (#3858) 2019-12-09 11:07:08 -08:00
TerminalApp.def Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
TerminalApp.vcxproj deps: upgrade CppWinRT to 2.0.200316.3, gsl to v2.1.0 (#4536) 2020-03-23 17:15:24 +00:00
TerminalPage.cpp Process actions sync. on startup; don't dupe nonexistent profile (#5090) 2020-03-25 17:03:32 -07:00
TerminalPage.h Process actions sync. on startup; don't dupe nonexistent profile (#5090) 2020-03-25 17:03:32 -07:00
TerminalPage.idl Process actions sync. on startup; don't dupe nonexistent profile (#5090) 2020-03-25 17:03:32 -07:00
TerminalPage.xaml Enable dragging with the entire titlebar (#1948) 2019-07-18 17:21:33 -05:00
TerminalWarnings.h Add warning messages for bad keybindings (#4746) 2020-03-05 21:06:58 +00:00
TitlebarControl.cpp Unify and clean up the common build properties (#3429) 2019-11-05 14:29:11 -08:00
TitlebarControl.h Upgrade to Microsoft.UI.Xaml 2.2 (#3027) 2019-10-14 22:41:43 -07:00
TitlebarControl.idl Upgrade to Microsoft.UI.Xaml 2.2 (#3027) 2019-10-14 22:41:43 -07:00
TitlebarControl.xaml Upgrade to Microsoft.UI.Xaml 2.2 (#3027) 2019-10-14 22:41:43 -07:00
userDefaults.json Update stock user defaults to the list+defaults style (#4556) 2020-02-13 00:12:18 +00:00
Utils.cpp Fix a bunch of spelling errors across the project (#4295) 2020-02-10 20:40:01 +00:00
Utils.h Upgrade to Microsoft.UI.Xaml 2.2 (#3027) 2019-10-14 22:41:43 -07:00
WslDistroGenerator.cpp Force WslDistroGenerator to timeout after 10s and return Profiles (#4905) 2020-03-16 18:14:25 +00:00
WslDistroGenerator.h Add Dynamic Profile Generators (#2603) 2019-09-16 13:34:27 -07:00