From: Simon Tatham Date: Sat, 3 Feb 2024 12:06:04 +0000 (+0000) Subject: Fix character counting in masked passwords. X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=da72dd0e3b980dd5ac1fca941d00713efef8451c;p=mastodonochrome.git 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. --- 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() }