diff --git a/src/cascadia/TerminalApp/Resources/en-US/Resources.resw b/src/cascadia/TerminalApp/Resources/en-US/Resources.resw index 3f122114070..0975dacc650 100644 --- a/src/cascadia/TerminalApp/Resources/en-US/Resources.resw +++ b/src/cascadia/TerminalApp/Resources/en-US/Resources.resw @@ -405,7 +405,7 @@ Cancel - + You are about to paste text that contains multiple lines. If you paste this text into your shell, it may result in the unexpected execution of commands. Do you wish to continue? @@ -527,4 +527,7 @@ Warning + + Clipboard contents (preview): + diff --git a/src/cascadia/TerminalApp/TerminalPage.cpp b/src/cascadia/TerminalApp/TerminalPage.cpp index 335d09bc3d1..835692ef972 100644 --- a/src/cascadia/TerminalApp/TerminalPage.cpp +++ b/src/cascadia/TerminalApp/TerminalPage.cpp @@ -1957,6 +1957,13 @@ namespace winrt::TerminalApp::implementation { co_await winrt::resume_foreground(Dispatcher()); + // We have to initialize the dialog here to be able to change the text of the text block within it + FindName(L"MultiLinePasteDialog").try_as(); + ClipboardText().Text(text); + + // The vertical offset on the scrollbar does not reset automatically, so reset it manually + ClipboardContentScrollViewer().ScrollToVerticalOffset(0); + ContentDialogResult warningResult; if (warnMultiLine) { @@ -1967,6 +1974,9 @@ namespace winrt::TerminalApp::implementation warningResult = co_await _ShowLargePasteWarningDialog(); } + // Clear the clipboard text so it doesn't lie around in memory + ClipboardText().Text(L""); + if (warningResult != ContentDialogResult::Primary) { // user rejected the paste diff --git a/src/cascadia/TerminalApp/TerminalPage.xaml b/src/cascadia/TerminalApp/TerminalPage.xaml index 40c3100a5e4..109828933f5 100644 --- a/src/cascadia/TerminalApp/TerminalPage.xaml +++ b/src/cascadia/TerminalApp/TerminalPage.xaml @@ -58,6 +58,26 @@ the MIT License. See LICENSE in the project root for license information. --> x:Name="MultiLinePasteDialog" x:Uid="MultiLinePasteDialog" DefaultButton="Primary"> + + + + + + + + + +