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 ( )
@@ -89,12 +90,11 @@ private void ListBox_PreviewMouseDown(object sender, MouseButtonEventArgs e)
8990 }
9091 }
9192
92-
93- private Point start ;
94- private string path ;
95- private string query ;
93+ private Point _start ;
94+ private string _path ;
95+ private string _trimmedQuery ;
9696 // this method is called by the UI thread, which is single threaded, so we can be sloppy with locking
97- private bool isDragging ;
97+ private bool _isDragging ;
9898
9999 private void ResultList_PreviewMouseLeftButtonDown ( object sender , MouseButtonEventArgs e )
100100 {
@@ -105,60 +105,63 @@ private void ResultList_PreviewMouseLeftButtonDown(object sender, MouseButtonEve
105105 Result :
106106 {
107107 CopyText : { } copyText ,
108- OriginQuery . RawQuery : { } rawQuery
108+ OriginQuery . TrimmedQuery : { } trimmedQuery
109109 }
110110 }
111111 } ) return ;
112112
113- path = copyText ;
114- query = rawQuery ;
115- start = e . GetPosition ( null ) ;
116- isDragging = true ;
113+ _path = copyText ;
114+ _trimmedQuery = trimmedQuery ;
115+ _start = e . GetPosition ( null ) ;
116+ _isDragging = true ;
117117 }
118+
118119 private void ResultList_MouseMove ( object sender , MouseEventArgs e )
119120 {
120- if ( e . LeftButton != MouseButtonState . Pressed || ! isDragging )
121+ if ( e . LeftButton != MouseButtonState . Pressed || ! _isDragging )
121122 {
122- start = default ;
123- path = string . Empty ;
124- query = string . Empty ;
125- isDragging = false ;
123+ _start = default ;
124+ _path = string . Empty ;
125+ _trimmedQuery = string . Empty ;
126+ _isDragging = false ;
126127 return ;
127128 }
128129
129- if ( ! File . Exists ( path ) && ! Directory . Exists ( path ) )
130+ if ( ! File . Exists ( _path ) && ! Directory . Exists ( _path ) )
130131 return ;
131132
132133 Point mousePosition = e . GetPosition ( null ) ;
133- Vector diff = this . start - mousePosition ;
134+ Vector diff = _start - mousePosition ;
134135
135136 if ( Math . Abs ( diff . X ) < SystemParameters . MinimumHorizontalDragDistance
136137 || Math . Abs ( diff . Y ) < SystemParameters . MinimumVerticalDragDistance )
137138 return ;
138139
139- isDragging = false ;
140+ _isDragging = false ;
140141
141142 App . API . HideMainWindow ( ) ;
142143
143144 var data = new DataObject ( DataFormats . FileDrop , new [ ]
144145 {
145- path
146+ _path
146147 } ) ;
147148
148149 // Reassigning query to a new variable because for some reason
149150 // after DragDrop.DoDragDrop call, 'query' loses its content, i.e. becomes empty string
150- var rawQuery = query ;
151+ var trimmedQuery = _trimmedQuery ;
151152 var effect = DragDrop . DoDragDrop ( ( DependencyObject ) sender , data , DragDropEffects . Move | DragDropEffects . Copy ) ;
152153 if ( effect == DragDropEffects . Move )
153- App . API . ChangeQuery ( rawQuery , true ) ;
154+ App . API . ChangeQuery ( trimmedQuery , true ) ;
154155 }
156+
155157 private void ResultListBox_OnPreviewMouseRightButtonDown ( object sender , MouseButtonEventArgs e )
156158 {
157159 if ( Mouse . DirectlyOver is not FrameworkElement { DataContext : ResultViewModel result } )
158160 return ;
159161
160162 RightClickResultCommand ? . Execute ( result . Result ) ;
161163 }
164+
162165 private void ResultListBox_OnPreviewMouseUp ( object sender , MouseButtonEventArgs e )
163166 {
164167 if ( Mouse . DirectlyOver is not FrameworkElement { DataContext : ResultViewModel result } )
0 commit comments