@@ -6,6 +6,8 @@ import * as rect from 'rectangle';
6
6
7
7
import { SearchOption } from 'launcher_service' ;
8
8
9
+ const GLib : GLib = imports . gi . GLib ;
10
+
9
11
const { Clutter, Shell, St } = imports . gi ;
10
12
const { ModalDialog } = imports . ui . modalDialog ;
11
13
@@ -52,7 +54,6 @@ export class Search {
52
54
53
55
this . active_id = 0 ;
54
56
this . widgets = [ ] ;
55
-
56
57
this . entry = new St . Entry ( {
57
58
style_class : "pop-shell-entry" ,
58
59
can_focus : true ,
@@ -65,13 +66,35 @@ export class Search {
65
66
( this . text as any ) . set_use_markup ( true )
66
67
this . dialog . setInitialKeyFocus ( this . text ) ;
67
68
68
- this . text . connect ( "activate" , ( ) => this . activate_option ( this . active_id ) ) ;
69
+ let text_changed : null | number = null ;
70
+
71
+ this . text . connect ( "activate" , ( ) => {
72
+ if ( text_changed !== null ) GLib . source_remove ( text_changed )
73
+ text_changed = null
74
+ this . activate_option ( this . active_id )
75
+ } ) ;
69
76
70
77
this . text . connect ( "text-changed" , ( entry : any ) => {
71
- this . clear ( ) ;
78
+ if ( text_changed !== null ) GLib . source_remove ( text_changed )
79
+
80
+ const text = ( entry as Clutter . Text ) . get_text ( ) . trim ( )
81
+
82
+ const update = ( ) => {
83
+ this . clear ( )
84
+ const update = search ( text )
85
+ if ( update ) this . update_search_list ( update )
86
+ }
87
+
88
+ if ( text . length === 0 ) {
89
+ update ( )
90
+ return
91
+ }
72
92
73
- const update = search ( ( entry as Clutter . Text ) . get_text ( ) . trim ( ) )
74
- if ( update ) this . update_search_list ( update )
93
+ text_changed = GLib . timeout_add ( GLib . PRIORITY_DEFAULT , 100 , ( ) => {
94
+ text_changed = null
95
+ update ( )
96
+ return false ;
97
+ } )
75
98
} ) ;
76
99
77
100
this . text . connect ( "key-press-event" , ( _ : any , event : any ) => {
0 commit comments