From ee9c53d2f9d1090724cd5181e08144137497b7d6 Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Sun, 4 Dec 2022 21:46:11 -0600 Subject: [PATCH 1/3] Add CopyText in Explorer Result --- .../Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs index e9cbfc2bd..8a12f1306 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs @@ -58,6 +58,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search SubTitle = Path.GetDirectoryName(path), AutoCompleteText = GetPathWithActionKeyword(path, ResultType.Folder), TitleHighlightData = StringMatcher.FuzzySearch(query.Search, title).MatchData, + CopyText = path, Action = c => { if (c.SpecialKeyState.CtrlPressed || (!Settings.PathSearchKeywordEnabled && !Settings.SearchActionKeywordEnabled)) @@ -174,7 +175,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search }, StringSplitOptions.None).Last(); var title = $"Open {folderName}"; - + var subtitleFolderName = folderName; // ie. max characters can be displayed without subtitle cutting off: "Program Files (x86)" @@ -189,6 +190,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search AutoCompleteText = GetPathWithActionKeyword(path, ResultType.Folder), IcoPath = path, Score = 500, + CopyText = path, Action = _ => { Context.API.OpenDirectory(path); @@ -213,6 +215,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search AutoCompleteText = GetPathWithActionKeyword(filePath, ResultType.File), TitleHighlightData = StringMatcher.FuzzySearch(query.Search, Path.GetFileName(filePath)).MatchData, Score = score, + CopyText = filePath, Action = c => { try From 5b6a18879c297b1f03b4e3f34695e8f55683c12b Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Sun, 4 Dec 2022 21:46:56 -0600 Subject: [PATCH 2/3] Fix Multiple Drag and drop causing NotReturn Method Call --- Flow.Launcher/ResultListBox.xaml.cs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Flow.Launcher/ResultListBox.xaml.cs b/Flow.Launcher/ResultListBox.xaml.cs index 6bd1490c3..e85f2b3d7 100644 --- a/Flow.Launcher/ResultListBox.xaml.cs +++ b/Flow.Launcher/ResultListBox.xaml.cs @@ -92,6 +92,8 @@ namespace Flow.Launcher private Point start; private string path; private string query; + // this method is called by the UI thread, which is single threaded, so we can be sloppy with locking + private bool isDragging; private void ResultList_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { @@ -101,15 +103,16 @@ namespace Flow.Launcher path = result.Result.CopyText; query = result.Result.OriginQuery.RawQuery; start = e.GetPosition(null); + isDragging = true; } - private void ResultList_MouseMove(object sender, MouseEventArgs e) { - if (e.LeftButton != MouseButtonState.Pressed) + if (e.LeftButton != MouseButtonState.Pressed|| !isDragging) { start = default; path = string.Empty; query = string.Empty; + isDragging = false; return; } @@ -123,15 +126,16 @@ namespace Flow.Launcher || Math.Abs(diff.Y) < SystemParameters.MinimumVerticalDragDistance) return; + isDragging = false; + var data = new DataObject(DataFormats.FileDrop, new[] { path }); - DragDrop.DoDragDrop((DependencyObject)sender, data, DragDropEffects.Move | DragDropEffects.Copy); - - App.API.ChangeQuery(query, true); - - e.Handled = true; + + var effect = DragDrop.DoDragDrop((DependencyObject)sender, data, DragDropEffects.Move | DragDropEffects.Copy); + if (effect == DragDropEffects.Move) + App.API.ChangeQuery(query, true); } private void ResultListBox_OnPreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e) { From 3415656d5bb1d327a343e318befd3591496ee607 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Mon, 5 Dec 2022 21:26:41 +1100 Subject: [PATCH 3/3] fix query becoming empty string after DoDragDrop call --- Flow.Launcher/ResultListBox.xaml.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Flow.Launcher/ResultListBox.xaml.cs b/Flow.Launcher/ResultListBox.xaml.cs index e85f2b3d7..bc784ab09 100644 --- a/Flow.Launcher/ResultListBox.xaml.cs +++ b/Flow.Launcher/ResultListBox.xaml.cs @@ -132,10 +132,13 @@ namespace Flow.Launcher { path }); - + + // Reassigning query to a new variable because for some reason + // after DragDrop.DoDragDrop call, 'query' loses its content, i.e. becomes empty string + var rawQuery = query; var effect = DragDrop.DoDragDrop((DependencyObject)sender, data, DragDropEffects.Move | DragDropEffects.Copy); if (effect == DragDropEffects.Move) - App.API.ChangeQuery(query, true); + App.API.ChangeQuery(rawQuery, true); } private void ResultListBox_OnPreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e) {