fix(search): mark a match count that hit the ceiling

The scrollback scan stops at 10,000 matches. The count rendered that as
"1/10000", which reads as the whole truth — a search for a common
letter looked like it had found every occurrence and settled on a round
number.

It now reads "1/10000+" once the ceiling is reached, the same way every
search that caps says so.
This commit is contained in:
l0ng-ai
2026-08-08 05:50:50 +08:00
parent 1f91719da9
commit 4fc2dfd541
+20 -1
View File
@@ -276,11 +276,17 @@ impl TerminalView {
} else {
0
};
// The scan stops at MAX_MATCHES. Without the mark, a query that hit
// the ceiling reads as if the scrollback held exactly that many.
let more = match total >= MAX_MATCHES {
true => "+",
false => "",
};
div()
.flex_none()
.text_xs()
.text_color(muted)
.child(format!("{current}/{total}"))
.child(format!("{current}/{total}{more}"))
});
let case_toggle = Button::new("search-case")
@@ -733,6 +739,19 @@ pub(super) fn is_url_char(c: char) -> bool {
mod tests {
use super::*;
#[test]
fn a_capped_match_count_says_it_is_capped() {
// Same rule the count uses. Below the ceiling the number is the truth;
// at the ceiling it is a floor, and has to read like one.
let mark = |total: usize| match total >= MAX_MATCHES {
true => "+",
false => "",
};
assert_eq!(mark(0), "");
assert_eq!(mark(MAX_MATCHES - 1), "");
assert_eq!(mark(MAX_MATCHES), "+");
}
#[test]
fn regex_escape_neutralizes_metacharacters() {
assert_eq!(regex_escape("a.b*c"), r"a\.b\*c");