Show clipboard contents in multiple line paste warning dialog (#8744)
When we display a dialog to warn the user that they are doing a multi-line paste, we show the clipboard contents The contents are shown in a scroll viewer with a fixed maximum height. Closes #7997
This commit is contained in:
parent
20fc57ee0f
commit
aaf2395266
|
@ -415,7 +415,7 @@
|
|||
<data name="MultiLinePasteDialog.CloseButtonText" xml:space="preserve">
|
||||
<value>Cancel</value>
|
||||
</data>
|
||||
<data name="MultiLinePasteDialog.Content" xml:space="preserve">
|
||||
<data name="MultiLineWarningText.Text" xml:space="preserve">
|
||||
<value>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?</value>
|
||||
</data>
|
||||
<data name="MultiLinePasteDialog.PrimaryButtonText" xml:space="preserve">
|
||||
|
@ -537,4 +537,7 @@
|
|||
<data name="NoticeWarning" xml:space="preserve">
|
||||
<value>Warning</value>
|
||||
</data>
|
||||
<data name="ClipboardTextHeader.Text" xml:space="preserve">
|
||||
<value>Clipboard contents (preview):</value>
|
||||
</data>
|
||||
</root>
|
||||
|
|
|
@ -1960,6 +1960,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<WUX::Controls::ContentDialog>();
|
||||
ClipboardText().Text(text);
|
||||
|
||||
// The vertical offset on the scrollbar does not reset automatically, so reset it manually
|
||||
ClipboardContentScrollViewer().ScrollToVerticalOffset(0);
|
||||
|
||||
ContentDialogResult warningResult;
|
||||
if (warnMultiLine)
|
||||
{
|
||||
|
@ -1970,6 +1977,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
|
||||
|
|
|
@ -58,6 +58,26 @@ the MIT License. See LICENSE in the project root for license information. -->
|
|||
x:Name="MultiLinePasteDialog"
|
||||
x:Uid="MultiLinePasteDialog"
|
||||
DefaultButton="Primary">
|
||||
<StackPanel>
|
||||
<TextBlock
|
||||
x:Uid="MultiLineWarningText"
|
||||
TextWrapping="Wrap">
|
||||
</TextBlock>
|
||||
<TextBlock
|
||||
x:Uid="ClipboardTextHeader"
|
||||
Margin="0,16,0,0">
|
||||
</TextBlock>
|
||||
<ScrollViewer
|
||||
Margin="0,8,0,0"
|
||||
x:Name="ClipboardContentScrollViewer"
|
||||
MaxHeight="100">
|
||||
<TextBlock
|
||||
x:Name="ClipboardText"
|
||||
TextWrapping="Wrap"
|
||||
FontFamily="Cascadia Mono">
|
||||
</TextBlock>
|
||||
</ScrollViewer>
|
||||
</StackPanel>
|
||||
</ContentDialog>
|
||||
|
||||
<ContentDialog
|
||||
|
|
Loading…
Reference in a new issue