From 2bd164f11e8a80e2f04ea146a2a70d7747055433 Mon Sep 17 00:00:00 2001 From: Garulf <535299+Garulf@users.noreply.github.com> Date: Thu, 2 Dec 2021 04:39:54 -0500 Subject: [PATCH] Update clipboard only if needed We don't want to clear the clipboard if nothing is selected --- Flow.Launcher/MainWindow.xaml.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 9c233278f..ebc3dc874 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -49,18 +49,21 @@ namespace Flow.Launcher } private void OnCopy(object sender, ExecutedRoutedEventArgs e) { - var _NewClipboard = QueryTextBox.SelectedText; + if (QueryTextBox.SelectionLength == 0) { var results = _viewModel.Results; var result = results.SelectedItem?.Result; if (result != null) // SelectedItem returns null if selection is empty. { - _NewClipboard = result.Title.ToString(); + System.Windows.Clipboard.SetDataObject(result.Title.ToString()); } - + + } + else + { + System.Windows.Clipboard.SetDataObject(QueryTextBox.SelectedText;); } - System.Windows.Clipboard.SetDataObject(_NewClipboard); e.Handled = true; } private async void OnClosing(object sender, CancelEventArgs e)