-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement filter_mode
for both select
and multiselect
prompts
#49
Implement filter_mode
for both select
and multiselect
prompts
#49
Conversation
1. List renders through the `filter` always. 2. Rc<RefCell> is to handle a subset of filtered mutable references to the items from the same structure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cylewitruk @antoinePutmans I added a quick tour through the patch for you. It implements filtering for both select
and mutliselect
on top of the previous PR. Welcome to test!
} | ||
} | ||
} | ||
self.filter.set(self.items.to_vec()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, the self.filter
is initiated to all items.
@@ -94,24 +115,34 @@ impl<T: Clone> PromptInteraction<Vec<T>> for MultiSelect<T> { | |||
fn on(&mut self, event: &Event) -> State<Vec<T>> { | |||
let Event::Key(key) = event; | |||
|
|||
if let Some(state) = self.filter.on(key, self.items.clone()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, filter is updated.
src/multiselect.rs
Outdated
for (i, item) in self.items.iter().enumerate() { | ||
line2.push_str(&theme.format_multiselect_item( | ||
let mut items_render = String::new(); | ||
for (i, item) in self.filter.items().iter().map(|i| i.borrow()).enumerate() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then, just replacing self.items
to self.filter.items()
. The same in Select
.
Will give it a try tomorrow! 😄 |
Good job @fadeevab 💪 I will test it tomorrow as well 😄 |
@fadeevab Hey, I tested the new feature, it works fine 👍 Screen.Recording.2024-05-04.at.19.31.21.movFor example here, Prettier wont be in the result even if he's selected. |
Interesting, I haven't thought about it... I think a similar problem is in the |
@antoinePutmans Okay, I did this: it holds the item selection for multi-select list even when they are filtered out and after |
Superseded by PR #52 |
self.filter
always.Rc<RefCell>
is to handle a subset of filtered mutable references to the items from thesame structure.