File tree 2 files changed +16
-2
lines changed
2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ use egui::{Context, Ui};
4
4
5
5
use crate :: {
6
6
config:: { ConfigBuilder , ConfigError } ,
7
+ theme:: list:: ListState ,
7
8
GlutinWindowContext ,
8
9
} ;
9
10
@@ -95,6 +96,8 @@ pub trait Plugin {
95
96
pub struct PluginManager {
96
97
plugins : Vec < Box < dyn Plugin > > ,
97
98
config_plugins : Vec < String > ,
99
+ /// the nth plugin returned PluginFlowControl::break during search
100
+ flow_broke_at : usize ,
98
101
}
99
102
impl PluginManager {
100
103
pub fn new ( ) -> Self {
@@ -153,9 +156,14 @@ impl PluginManager {
153
156
return ;
154
157
}
155
158
156
- for i in & mut self . plugins {
157
- i . search ( ui, ctx) ;
159
+ for ( i , plugin ) in & mut self . plugins . iter_mut ( ) . enumerate ( ) {
160
+ plugin . search ( ui, ctx) ;
158
161
if let PluginFlowControl :: Break = ctx. flow {
162
+ // Clear the list on switching between plugins
163
+ if self . flow_broke_at != i {
164
+ ListState :: clear ( ui. ctx ( ) ) ;
165
+ self . flow_broke_at = i;
166
+ }
159
167
break ;
160
168
}
161
169
}
Original file line number Diff line number Diff line change @@ -95,4 +95,10 @@ impl ListState {
95
95
pub fn reset ( ctx : & Context , selected_row : i32 ) {
96
96
ctx. data_mut ( |d| d. insert_persisted ( Id :: new ( LIST_ID ) , Self :: new ( selected_row) ) ) ;
97
97
}
98
+ pub fn clear ( ctx : & Context ) {
99
+ let current: Option < Self > = ctx. data_mut ( |d| d. get_persisted ( Id :: new ( LIST_ID ) ) ) ;
100
+ if current. is_some ( ) {
101
+ ctx. data_mut ( |d| d. remove :: < Self > ( Id :: new ( LIST_ID ) ) ) ;
102
+ }
103
+ }
98
104
}
You can’t perform that action at this time.
0 commit comments