Teach TerminalPage to handle exceptions that happen during paste (#5856)

Terminal should try not to join the choir invisible when the clipboard
API straight up horks it.

This accounts for ~3% of the crashes seen in 1.0RC1 and ~1% of the
crashes seen all-up in the last 14 days.

## Repro (prior to this commit)
Set `"copyOnSelect": true`.

Copy something small.

Hold down <kbd>Ctrl+Shift+V</kbd>

Double-click like your life depends on it. Double-click like you're
playing cookie clicker again. 2013 called, it wants its cookies back.

Fixes #4906.
This commit is contained in:
Dustin L. Howett (MSFT) 2020-05-12 11:23:58 -07:00 committed by GitHub
parent fcd5bb39f0
commit a99c812794
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1448,12 +1448,16 @@ namespace winrt::TerminalApp::implementation
// will crash on the UI thread, because the main thread is a STA.
co_await winrt::resume_background();
hstring text = L"";
if (data.Contains(StandardDataFormats::Text()))
try
{
text = co_await data.GetTextAsync();
hstring text = L"";
if (data.Contains(StandardDataFormats::Text()))
{
text = co_await data.GetTextAsync();
}
eventArgs.HandleClipboardData(text);
}
eventArgs.HandleClipboardData(text);
CATCH_LOG();
}
// Method Description: