Skip to content

Commit

Permalink
Teach TerminalPage to handle exceptions that happen during paste (#5856)
Browse files Browse the repository at this point in the history
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.

(cherry picked from commit a99c812)
  • Loading branch information
DHowett committed May 12, 2020
1 parent 36c5b5b commit c31c857
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/cascadia/TerminalApp/TerminalPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1419,12 +1419,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:
Expand Down

0 comments on commit c31c857

Please sign in to comment.