diff --git a/src/app/browser/window/tab/item/page/search/form/navigation.rs b/src/app/browser/window/tab/item/page/search/form/navigation.rs index c1d993e5..c57a293d 100644 --- a/src/app/browser/window/tab/item/page/search/form/navigation.rs +++ b/src/app/browser/window/tab/item/page/search/form/navigation.rs @@ -95,7 +95,7 @@ impl Navigation { } } - pub fn position(&self) -> usize { + pub fn position(&self) -> Option { self.model.borrow().position() } diff --git a/src/app/browser/window/tab/item/page/search/form/navigation/model.rs b/src/app/browser/window/tab/item/page/search/form/navigation/model.rs index 180556de..744afa54 100644 --- a/src/app/browser/window/tab/item/page/search/form/navigation/model.rs +++ b/src/app/browser/window/tab/item/page/search/form/navigation/model.rs @@ -24,7 +24,7 @@ impl Model { self.vector.get(self.cursor.as_index()) } - pub fn position(&self) -> usize { + pub fn position(&self) -> Option { self.cursor.as_position() } diff --git a/src/app/browser/window/tab/item/page/search/form/navigation/model/cursor.rs b/src/app/browser/window/tab/item/page/search/form/navigation/model/cursor.rs index 3330812c..877500ce 100644 --- a/src/app/browser/window/tab/item/page/search/form/navigation/model/cursor.rs +++ b/src/app/browser/window/tab/item/page/search/form/navigation/model/cursor.rs @@ -35,7 +35,11 @@ impl Cursor { } } - pub fn as_position(&self) -> usize { - self.current + pub fn as_position(&self) -> Option { + if self.current > 0 { + Some(self.current) + } else { + None + } } } diff --git a/src/app/browser/window/tab/item/page/search/form/result.rs b/src/app/browser/window/tab/item/page/search/form/result.rs index e6c305ad..174b2dc5 100644 --- a/src/app/browser/window/tab/item/page/search/form/result.rs +++ b/src/app/browser/window/tab/item/page/search/form/result.rs @@ -22,13 +22,13 @@ impl Result { // Actions - pub fn update(&self, current: usize, total: usize) { + pub fn update(&self, current: Option, total: usize) { if total > 0 { - if current > 0 { - self.label - .set_label(&format!("{current} of {total} matches")); - } else { - self.label.set_label(&format!("{total} matches")); + match current { + Some(position) => self + .label + .set_label(&format!("{position} of {total} matches")), + None => self.label.set_label(&format!("{total} matches")), } self.label.remove_css_class("error"); } else {