cleanup + proper loading bar

This commit is contained in:
Simon Gardling
2022-05-11 10:26:36 -04:00
parent 42596be571
commit e6bee04113
7 changed files with 78 additions and 57 deletions

View File

@@ -22,24 +22,24 @@ pub struct AutoComplete<'a> {
}
impl<'a> const Default for AutoComplete<'a> {
fn default() -> AutoComplete<'a> {
AutoComplete {
i: 0,
hint: &suggestions::HINT_EMPTY,
string: String::new(),
}
}
fn default() -> AutoComplete<'a> { AutoComplete::EMPTY }
}
impl<'a> AutoComplete<'a> {
const EMPTY: AutoComplete<'a> = Self {
i: 0,
hint: &suggestions::HINT_EMPTY,
string: String::new(),
};
#[allow(dead_code)]
pub fn update_string(&mut self, string: &str) {
if self.string != string {
// catch empty strings here to avoid call to `generate_hint` and unnecessary logic
if string.is_empty() {
*self = Self::default();
*self = Self::EMPTY;
} else {
self.string = string.to_string();
self.string = string.to_owned();
self.do_update_logic();
}
}