Skip to content

Commit

Permalink
fix(ui/single_select): Added a Default implementation for SelectForm …
Browse files Browse the repository at this point in the history
…using SelectFormBuilder

Added a Default implementation for SelectForm using SelectFormBuilder.
This change ensures that SelectForm can be instantiated with default
values, improving usability and consistency.
  • Loading branch information
sarub0b0 committed Oct 24, 2024
1 parent 5428277 commit de00561
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/ui/widget/single_select/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,11 @@ impl SelectFormBuilder {
list_widget = list_widget.widget_base(self.widget_base);

SelectForm {
list_items: BTreeSet::new(),
list_widget: list_widget.build(),
..Default::default()
filter: "".to_string(),
chunk: Rect::default(),
matcher: SkimMatcherV2::default(),
}
}
}
Expand All @@ -77,7 +80,7 @@ impl Default for SelectFormBuilder {
}

#[derive(Derivative)]
#[derivative(Debug, Default)]
#[derivative(Debug)]
pub struct SelectForm<'a> {
list_items: BTreeSet<LiteralItem>,
list_widget: List<'a>,
Expand All @@ -87,6 +90,12 @@ pub struct SelectForm<'a> {
matcher: SkimMatcherV2,
}

impl Default for SelectForm<'_> {
fn default() -> Self {
SelectFormBuilder::default().build()
}
}

impl<'a> SelectForm<'a> {
pub fn builder() -> SelectFormBuilder {
SelectFormBuilder::default()
Expand Down

0 comments on commit de00561

Please sign in to comment.