@@ -82,7 +82,8 @@ pub struct AppEngine {
8282 pub ( super ) editing : Option < ElementOfInterest > ,
8383 /// For editing element text values
8484 pub ( super ) temp_file : PathBuf ,
85- pub ( super ) timeout_sender : Sender < usize > ,
85+ pub ( super ) signal_sender : Sender < AppSignal > ,
86+ pub ( super ) search_debounce_counter : usize ,
8687 /// Special treatment for Electron based apps.
8788 /// Like simulate mouse clicking instead of `element.press()`
8889 pub ( super ) last_app_window_info : AppWindowInfo ,
@@ -98,7 +99,7 @@ impl AppEngine {
9899 key_state : Arc < Mutex < KeyState > > ,
99100 config : GlyphlowConfig ,
100101 temp_file : PathBuf ,
101- timeout_sender : Sender < usize > ,
102+ signal_sender : Sender < AppSignal > ,
102103 ) -> Self {
103104 let mtm = MainThreadMarker :: new ( ) . expect ( "Not on main thread" ) ;
104105 let screen_frames = get_screen_frames ( mtm) ;
@@ -125,7 +126,8 @@ impl AppEngine {
125126 overlay_frame,
126127 drawer,
127128 config,
128- timeout_sender,
129+ signal_sender,
130+ search_debounce_counter : 0 ,
129131 selected : None ,
130132 editing : None ,
131133 temp_file,
@@ -149,13 +151,17 @@ impl AppEngine {
149151 AppSignal :: DeActivate => {
150152 self . deactivate ( ) ;
151153 }
154+ AppSignal :: MenuRefresh ( key_prefix) => {
155+ self . menu_refresh ( & key_prefix, false ) ;
156+ }
152157 AppSignal :: RunWorkFlow ( idx) => {
153158 self . drawer . clear_menus ( ) ;
154159 self . execute_workflow ( idx) ;
155160 }
156- AppSignal :: MenuRefresh ( key_prefix ) => {
157- self . menu_refresh ( & key_prefix , false ) ;
161+ AppSignal :: ScrollAction ( sa ) => {
162+ self . perform_scroll_action ( sa ) ;
158163 }
164+ AppSignal :: TextAction ( ta) => self . perform_text_action ( ta) ,
159165 AppSignal :: ToggleMultiSelection => match self . target {
160166 Target :: Text | Target :: ImageOCR => {
161167 self . toggle_multiselection ( ) ;
@@ -167,29 +173,36 @@ impl AppEngine {
167173 self . notify ( "Multi selection only works for text." , Level :: Warn ) ;
168174 }
169175 } ,
170- AppSignal :: Filter ( key_char, mode) => {
171- self . perform_filtering ( key_char, mode) . await ;
176+ AppSignal :: HintFilter ( key_char, mode) => {
177+ self . filter_by_hint ( key_char, mode) . await ;
172178 }
173- AppSignal :: ScrollAction ( sa) => {
174- self . perform_scroll_action ( sa) ;
179+ AppSignal :: SearchFilter ( key_char, mode) => {
180+ self . filter_by_search ( key_char, mode) . await ;
181+ }
182+ AppSignal :: SearchDebounce ( id, mode) => {
183+ if self . is_searching && id == self . search_debounce_counter {
184+ self . check_filtering ( mode) . await ;
185+ }
175186 }
176- AppSignal :: TextAction ( ta) => self . perform_text_action ( ta) ,
177187 AppSignal :: StartSearch => {
178188 if self . is_searching {
179189 return ;
180190 }
181191 self . is_searching = true ;
192+ self . drawer . draw_search_bar ( & self . search_prefix , true ) ;
182193 if self . word_picker . is_some ( ) {
183194 self . draw_word_picker ( ) ;
184195 } else {
185- self . drawer . draw_search_bar ( & self . search_prefix , true ) ;
186196 self . build_search_targets ( ) ;
187197 }
188198 }
189199 AppSignal :: FinishSearch ( mode) => {
190200 self . is_searching = false ;
201+ self . search_debounce_counter = self . search_debounce_counter . wrapping_add ( 1 ) ;
191202 self . set_mode ( mode. to_app_mode ( ) ) ;
192- if self . word_picker . is_none ( ) {
203+ if self . word_picker . is_some ( ) {
204+ self . drawer . hide_search_bar ( ) ;
205+ } else {
193206 self . drawer . clear_menus ( ) ;
194207 }
195208 self . check_filtering ( mode) . await ;
0 commit comments