Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions widget/src/combo_box.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,10 +383,17 @@ where

/// Pushes a new option to the [`State`].
pub fn push(&mut self, new_option: T) {
self.insert(self.options.len(), new_option);
}

/// Inserts a new option to the [`State`].
pub fn insert(&mut self, index: usize, new_option: T) {
let mut inner = self.inner.borrow_mut();

inner.option_matchers.push(build_matcher(&new_option));
self.options.push(new_option);
inner
.option_matchers
.insert(index, build_matcher(&new_option));
self.options.insert(index, new_option);

inner.filtered_options = Filtered::new(
search(&self.options, &inner.option_matchers, &inner.value)
Expand Down