From 811b872f4ecce64f051e84cc27872fee14e10858 Mon Sep 17 00:00:00 2001 From: tachyglossues <81535731+tachyglossues@users.noreply.github.com> Date: Wed, 8 Jan 2025 03:39:53 +0100 Subject: [PATCH] =?UTF-8?q?Fix=20no=20whitespace=20displaying=20after=20an?= =?UTF-8?q?=20"=C3=A0=20"=20(#22403)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixed a bug where with the "show_whitespaces": "boundary" option, when there was an "à" followed by a space, a white space was displayed, and when "à" was at the end of the line, a white space was added Release Notes: - N/A --------- Co-authored-by: Conrad Irwin --- crates/editor/src/element.rs | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index 8580acc15a772925b515afe4afb4b95e106943bc..509ea6bf4facdf45428f8ea1d9af2aefd2def9e4 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -5578,21 +5578,21 @@ impl LineWithInvisibles { }); } } else { - invisibles.extend( - line_chunk - .bytes() - .enumerate() - .filter(|(_, line_byte)| { - let is_whitespace = - (*line_byte as char).is_whitespace(); - non_whitespace_added |= !is_whitespace; - is_whitespace - && (non_whitespace_added || !is_soft_wrapped) - }) - .map(|(whitespace_index, _)| Invisible::Whitespace { - line_offset: line.len() + whitespace_index, - }), - ) + invisibles.extend(line_chunk.char_indices().filter_map( + |(index, c)| { + let is_whitespace = c.is_whitespace(); + non_whitespace_added |= !is_whitespace; + if is_whitespace + && (non_whitespace_added || !is_soft_wrapped) + { + Some(Invisible::Whitespace { + line_offset: line.len() + index, + }) + } else { + None + } + }, + )) } }