File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed
Expand file tree Collapse file tree 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};
44
55use crate :: {
66 config:: { ConfigBuilder , ConfigError } ,
7+ theme:: list:: ListState ,
78 GlutinWindowContext ,
89} ;
910
@@ -95,6 +96,8 @@ pub trait Plugin {
9596pub struct PluginManager {
9697 plugins : Vec < Box < dyn Plugin > > ,
9798 config_plugins : Vec < String > ,
99+ /// the nth plugin returned PluginFlowControl::break during search
100+ flow_broke_at : usize ,
98101}
99102impl PluginManager {
100103 pub fn new ( ) -> Self {
@@ -153,9 +156,14 @@ impl PluginManager {
153156 return ;
154157 }
155158
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) ;
158161 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+ }
159167 break ;
160168 }
161169 }
Original file line number Diff line number Diff line change @@ -95,4 +95,10 @@ impl ListState {
9595 pub fn reset ( ctx : & Context , selected_row : i32 ) {
9696 ctx. data_mut ( |d| d. insert_persisted ( Id :: new ( LIST_ID ) , Self :: new ( selected_row) ) ) ;
9797 }
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+ }
98104}
You can’t perform that action at this time.
0 commit comments