@@ -26,7 +26,7 @@ impl Pass {
26
26
Default :: default ( )
27
27
}
28
28
29
- fn list_passwords ( & self ) -> Result < Vec < String > , Box < dyn Error > > {
29
+ fn list_passwords ( & self , keyword : & str ) -> Result < Vec < String > , Box < dyn Error > > {
30
30
let call = Command :: new ( "bash" )
31
31
. stdout ( Stdio :: piped ( ) )
32
32
. stderr ( Stdio :: piped ( ) )
@@ -41,7 +41,11 @@ impl Pass {
41
41
}
42
42
43
43
let stdout = String :: from_utf8_lossy ( & call. stdout ) ;
44
- let passwords = stdout. lines ( ) . map ( ToString :: to_string) . collect ( ) ;
44
+ let passwords = stdout
45
+ . lines ( )
46
+ . filter ( |name| name. contains ( keyword) )
47
+ . map ( ToString :: to_string)
48
+ . collect ( ) ;
45
49
Ok ( passwords)
46
50
}
47
51
@@ -131,13 +135,19 @@ impl Plugin for Pass {
131
135
ui : & mut egui:: Ui ,
132
136
gl_window : & crate :: windowing:: GlutinWindowContext ,
133
137
) -> PluginFlowControl {
134
- if !query. starts_with ( "pass_plugin" ) {
138
+ if !query. starts_with ( & self . config_prefix ) {
135
139
return PluginFlowControl :: Continue ;
136
140
}
137
- match self . list_passwords ( ) {
141
+
142
+ let keyword = query
143
+ . strip_prefix ( & self . config_prefix )
144
+ . unwrap_or_default ( )
145
+ . trim ( ) ;
146
+ match self . list_passwords ( keyword) {
138
147
Ok ( passwords) => {
139
148
const NUMBER_OF_BUTTONS : usize = 2 ;
140
- self . list . update ( ui. ctx ( ) , passwords. len ( ) , |_| NUMBER_OF_BUTTONS ) ;
149
+ self . list
150
+ . update ( ui. ctx ( ) , passwords. len ( ) , |_| NUMBER_OF_BUTTONS ) ;
141
151
ui. list ( self . list , |mut ui| {
142
152
for pw in passwords {
143
153
ui. row ( |mut ui| {
0 commit comments