Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Fix no whitespace displaying after an "à " (#22403)

tachyglossues811b872f4ecc
diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs
index 8580acc15a7..509ea6bf4fa 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
+ }
+ },
+ ))
}
}