@@ -92,6 +92,8 @@ private void ListBox_PreviewMouseDown(object sender, MouseButtonEventArgs e)
92
92
private Point start ;
93
93
private string path ;
94
94
private string query ;
95
+ // this method is called by the UI thread, which is single threaded, so we can be sloppy with locking
96
+ private bool isDragging ;
95
97
96
98
private void ResultList_PreviewMouseLeftButtonDown ( object sender , MouseButtonEventArgs e )
97
99
{
@@ -101,15 +103,16 @@ private void ResultList_PreviewMouseLeftButtonDown(object sender, MouseButtonEve
101
103
path = result . Result . CopyText ;
102
104
query = result . Result . OriginQuery . RawQuery ;
103
105
start = e . GetPosition ( null ) ;
106
+ isDragging = true ;
104
107
}
105
-
106
108
private void ResultList_MouseMove ( object sender , MouseEventArgs e )
107
109
{
108
- if ( e . LeftButton != MouseButtonState . Pressed )
110
+ if ( e . LeftButton != MouseButtonState . Pressed || ! isDragging )
109
111
{
110
112
start = default ;
111
113
path = string . Empty ;
112
114
query = string . Empty ;
115
+ isDragging = false ;
113
116
return ;
114
117
}
115
118
@@ -123,15 +126,19 @@ private void ResultList_MouseMove(object sender, MouseEventArgs e)
123
126
|| Math . Abs ( diff . Y ) < SystemParameters . MinimumVerticalDragDistance )
124
127
return ;
125
128
129
+ isDragging = false ;
130
+
126
131
var data = new DataObject ( DataFormats . FileDrop , new [ ]
127
132
{
128
133
path
129
134
} ) ;
130
- DragDrop . DoDragDrop ( ( DependencyObject ) sender , data , DragDropEffects . Move | DragDropEffects . Copy ) ;
131
-
132
- App . API . ChangeQuery ( query , true ) ;
133
135
134
- e . Handled = true ;
136
+ // Reassigning query to a new variable because for some reason
137
+ // after DragDrop.DoDragDrop call, 'query' loses its content, i.e. becomes empty string
138
+ var rawQuery = query ;
139
+ var effect = DragDrop . DoDragDrop ( ( DependencyObject ) sender , data , DragDropEffects . Move | DragDropEffects . Copy ) ;
140
+ if ( effect == DragDropEffects . Move )
141
+ App . API . ChangeQuery ( rawQuery , true ) ;
135
142
}
136
143
private void ResultListBox_OnPreviewMouseRightButtonDown ( object sender , MouseButtonEventArgs e )
137
144
{
0 commit comments