terminal/src/cascadia/TerminalControl
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
..
Resources/en-US Prepare for automated localization (#5119) 2020-03-25 21:06:59 +00:00
init.cpp Fix Search non-blocking follow-ups (#4028) 2019-12-20 17:35:31 -08: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
pch.cpp Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
pch.h Show InputPanel on focus and pointer press (#4867) 2020-03-10 17:55:57 +00:00
SearchBoxControl.cpp Fix Search non-blocking follow-ups (#4028) 2019-12-20 17:35:31 -08:00
SearchBoxControl.h Fix Search non-blocking follow-ups (#4028) 2019-12-20 17:35:31 -08:00
SearchBoxControl.idl Fix a bunch of spelling errors across the project (#4295) 2020-02-10 20:40:01 +00:00
SearchBoxControl.xaml Fix the case sensitivity button in search on High Contrast (#5088) 2020-03-23 11:24:27 -07:00
TermControl.cpp Process actions sync. on startup; don't dupe nonexistent profile (#5090) 2020-03-25 17:03:32 -07:00
TermControl.h Rework and simplify selection in TermControl (#5096) 2020-03-25 21:09:49 +00:00
TermControl.idl Abstract GetTextForClipboard() for UIA (#4578) 2020-03-09 08:17:34 -07:00
TermControl.xaml Polish AutomationProperties and UIA Tree Navigation (#4805) 2020-03-05 22:32:46 +00:00
TermControlAutomationPeer.cpp Fire UIA Events for Output and Cursor Movement (#4826) 2020-03-18 18:01:05 +00:00
TermControlAutomationPeer.h Define Automation Properties for TermControl (#4732) 2020-02-27 16:37:56 -08:00
TermControlAutomationPeer.idl Attach UiaRenderer and Fire Selection Changed Events (#2989) 2019-12-11 13:52:49 -08:00
TerminalControl.def Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
TerminalControl.vcxproj Prepare for automated localization (#5119) 2020-03-25 21:06:59 +00:00
TerminalControl.vcxproj.filters Prepare for automated localization (#5119) 2020-03-25 21:06:59 +00:00
TSFInputControl.cpp Process actions sync. on startup; don't dupe nonexistent profile (#5090) 2020-03-25 17:03:32 -07:00
TSFInputControl.h Make Korean IME input more consistent (#4796) 2020-03-04 20:01:01 +00:00
TSFInputControl.idl Make Korean IME input more consistent (#4796) 2020-03-04 20:01:01 +00:00
TSFInputControl.xaml Allow IME Text Wrapping (#5005) 2020-03-19 19:15:13 +00:00
XamlUiaTextRange.cpp hook up UIA tree to WPF control (#4548) 2020-02-24 23:17:55 +00:00
XamlUiaTextRange.h hook up UIA tree to WPF control (#4548) 2020-02-24 23:17:55 +00:00