From da72dd0e3b980dd5ac1fca941d00713efef8451c Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sat, 3 Feb 2024 12:06:04 +0000 Subject: [PATCH] Fix character counting in masked passwords. Thanks to Ian for picking this out of Clippy's huge output dump: when counting the things in a str that EditorCore would regard as characters, we were using 'map' rather than 'filter' to pick out things with positive terminal width, which had no effect on the following .count(). So a Unicode combining character would display an extra * in the masked password when _not_ editing it, compared to when editing it. --- src/editor.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/editor.rs b/src/editor.rs index 2d6a28e..6670d9b 100644 --- a/src/editor.rs +++ b/src/editor.rs @@ -839,7 +839,7 @@ pub struct EditableMenuLine { pub fn count_edit_chars(text: &str) -> usize { text.chars() - .map(|c| UnicodeWidthChar::width(c).unwrap_or(0) > 0) + .filter(|c| UnicodeWidthChar::width(*c).unwrap_or(0) > 0) .count() } -- 2.30.2