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.

Revert unnecessary "fix handling of unicode when counting codeblock lines" + document (#30368)

Michael Sloan30f3efe6976c
diff --git a/crates/markdown/src/markdown.rs b/crates/markdown/src/markdown.rs
index 8ef88901f3c..998a180e63b 100644
--- a/crates/markdown/src/markdown.rs
+++ b/crates/markdown/src/markdown.rs
@@ -223,6 +223,7 @@ impl Markdown {
}
pub fn escape(s: &str) -> Cow<str> {
+ // Valid to use bytes since multi-byte UTF-8 doesn't use ASCII chars.
let count = s
.bytes()
.filter(|c| *c == b'\n' || c.is_ascii_punctuation())
diff --git a/crates/markdown/src/parser.rs b/crates/markdown/src/parser.rs
index e5e58472894..debfe5245f5 100644
--- a/crates/markdown/src/parser.rs
+++ b/crates/markdown/src/parser.rs
@@ -79,9 +79,10 @@ pub fn parse_markdown(
let content_range =
content_range.start + range.start..content_range.end + range.start;
+ // Valid to use bytes since multi-byte UTF-8 doesn't use ASCII chars.
let line_count = text[content_range.clone()]
- .chars()
- .filter(|c| *c == '\n')
+ .bytes()
+ .filter(|c| *c == b'\n')
.count();
let metadata = CodeBlockMetadata {
content_range,