From 5e3fdf3320708511b32cbaf940e016e7c309c2ca Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Thu, 7 Nov 2024 07:26:44 +0100 Subject: [PATCH] Fix regression causing crash when we should clamp negative wcwidth Fixes c41dbe455 (Also use control pictures for pager prefix, 2024-10-19). Fixes #10836 --- src/screen.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/screen.rs b/src/screen.rs index 5303b07d6..8eff0f5e7 100644 --- a/src/screen.rs +++ b/src/screen.rs @@ -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() }