Fix regression causing crash when we should clamp negative wcwidth
Some checks are pending
make test / ubuntu (push) Waiting to run
make test / ubuntu-32bit-static-pcre2 (push) Waiting to run
make test / ubuntu-asan (push) Waiting to run
make test / macos (push) Waiting to run
Rust checks / rustfmt (push) Waiting to run
Rust checks / clippy (push) Waiting to run

Fixes c41dbe455 (Also use control pictures for pager prefix,
2024-10-19).

Fixes #10836
This commit is contained in:
Johannes Altmanninger 2024-11-07 07:26:44 +01:00
parent 373c5b1e14
commit 5e3fdf3320

View File

@ -1953,11 +1953,11 @@ fn rendered_character(c: char) -> char {
}
fn wcwidth_rendered_min_0(c: char) -> usize {
usize::try_from(wcwidth_rendered(c)).unwrap()
usize::try_from(wcwidth_rendered(c)).unwrap_or_default()
}
pub fn wcwidth_rendered(c: char) -> isize {
fish_wcwidth(rendered_character(c))
}
pub fn wcswidth_rendered(s: &wstr) -> isize {
s.chars().map(|c| fish_wcwidth(rendered_character(c))).sum()
s.chars().map(wcwidth_rendered).sum()
}