Merge pull request #2465 from Flow-Launcher/strip-newlines-for-multi-line-paste

Strip newlines for multi line paste
This commit is contained in:
Kevin Zhang 2024-01-15 20:05:37 -07:00 committed by GitHub
commit 6aeec622ae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View file

@ -221,6 +221,7 @@
Visibility="Visible">
<TextBox.CommandBindings>
<CommandBinding Command="ApplicationCommands.Copy" Executed="OnCopy" />
<CommandBinding Command="ApplicationCommands.Paste" Executed="OnPaste" />
</TextBox.CommandBindings>
<TextBox.ContextMenu>
<ContextMenu MinWidth="160">

View file

@ -71,6 +71,15 @@ namespace Flow.Launcher
App.API.CopyToClipboard(QueryTextBox.SelectedText, showDefaultNotification: false);
}
}
private void OnPaste(object sender, ExecutedRoutedEventArgs e)
{
if (System.Windows.Clipboard.ContainsText())
{
_viewModel.ChangeQueryText(System.Windows.Clipboard.GetText().Replace("\n", String.Empty).Replace("\r", String.Empty));
e.Handled = true;
}
}
private async void OnClosing(object sender, CancelEventArgs e)
{