11using System ;
22using System . IO ;
3+ using System . Threading ;
34using System . Windows ;
45using System . Windows . Controls ;
56using System . Windows . Input ;
@@ -9,7 +10,7 @@ namespace Flow.Launcher
910{
1011 public partial class ResultListBox
1112 {
12- protected object _lock = new object ( ) ;
13+ protected Lock _lock = new ( ) ;
1314 private Point _lastpos ;
1415 private ListBoxItem curItem = null ;
1516 public ResultListBox ( )
@@ -88,12 +89,11 @@ private void ListBox_PreviewMouseDown(object sender, MouseButtonEventArgs e)
8889 }
8990 }
9091
91-
92- private Point start ;
93- private string path ;
94- private string query ;
92+ private Point _start ;
93+ private string _path ;
94+ private string _trimmedQuery ;
9595 // this method is called by the UI thread, which is single threaded, so we can be sloppy with locking
96- private bool isDragging ;
96+ private bool _isDragging ;
9797
9898 private void ResultList_PreviewMouseLeftButtonDown ( object sender , MouseButtonEventArgs e )
9999 {
@@ -104,60 +104,63 @@ private void ResultList_PreviewMouseLeftButtonDown(object sender, MouseButtonEve
104104 Result :
105105 {
106106 CopyText : { } copyText ,
107- OriginQuery . RawQuery : { } rawQuery
107+ OriginQuery . TrimmedQuery : { } trimmedQuery
108108 }
109109 }
110110 } ) return ;
111111
112- path = copyText ;
113- query = rawQuery ;
114- start = e . GetPosition ( null ) ;
115- isDragging = true ;
112+ _path = copyText ;
113+ _trimmedQuery = trimmedQuery ;
114+ _start = e . GetPosition ( null ) ;
115+ _isDragging = true ;
116116 }
117+
117118 private void ResultList_MouseMove ( object sender , MouseEventArgs e )
118119 {
119- if ( e . LeftButton != MouseButtonState . Pressed || ! isDragging )
120+ if ( e . LeftButton != MouseButtonState . Pressed || ! _isDragging )
120121 {
121- start = default ;
122- path = string . Empty ;
123- query = string . Empty ;
124- isDragging = false ;
122+ _start = default ;
123+ _path = string . Empty ;
124+ _trimmedQuery = string . Empty ;
125+ _isDragging = false ;
125126 return ;
126127 }
127128
128- if ( ! File . Exists ( path ) && ! Directory . Exists ( path ) )
129+ if ( ! File . Exists ( _path ) && ! Directory . Exists ( _path ) )
129130 return ;
130131
131132 Point mousePosition = e . GetPosition ( null ) ;
132- Vector diff = this . start - mousePosition ;
133+ Vector diff = _start - mousePosition ;
133134
134135 if ( Math . Abs ( diff . X ) < SystemParameters . MinimumHorizontalDragDistance
135136 || Math . Abs ( diff . Y ) < SystemParameters . MinimumVerticalDragDistance )
136137 return ;
137138
138- isDragging = false ;
139+ _isDragging = false ;
139140
140141 App . API . HideMainWindow ( ) ;
141142
142143 var data = new DataObject ( DataFormats . FileDrop , new [ ]
143144 {
144- path
145+ _path
145146 } ) ;
146147
147148 // Reassigning query to a new variable because for some reason
148149 // after DragDrop.DoDragDrop call, 'query' loses its content, i.e. becomes empty string
149- var rawQuery = query ;
150+ var trimmedQuery = _trimmedQuery ;
150151 var effect = DragDrop . DoDragDrop ( ( DependencyObject ) sender , data , DragDropEffects . Move | DragDropEffects . Copy ) ;
151152 if ( effect == DragDropEffects . Move )
152- App . API . ChangeQuery ( rawQuery , true ) ;
153+ App . API . ChangeQuery ( trimmedQuery , true ) ;
153154 }
155+
154156 private void ResultListBox_OnPreviewMouseRightButtonDown ( object sender , MouseButtonEventArgs e )
155157 {
156158 if ( Mouse . DirectlyOver is not FrameworkElement { DataContext : ResultViewModel result } )
157159 return ;
158160
159161 RightClickResultCommand ? . Execute ( result . Result ) ;
160162 }
163+
161164 private void ResultListBox_OnPreviewMouseUp ( object sender , MouseButtonEventArgs e )
162165 {
163166 if ( Mouse . DirectlyOver is not FrameworkElement { DataContext : ResultViewModel result } )
0 commit comments