Skip to content

Commit dbd0b03

Browse files
committed
Auto merge of rust-lang#16155 - Waqar144:work/fix-16142, r=lnicola
fix: Dont assume ascii in remove_markdown Fixes rust-lang#16142
2 parents 1c4c220 + 5318e89 commit dbd0b03

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

crates/ide/src/markdown_remove.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ pub(crate) fn remove_markdown(markdown: &str) -> String {
2323
}
2424
}
2525

26-
if let Some(p) = out.rfind(|c| c != '\n') {
26+
if let Some(mut p) = out.rfind(|c| c != '\n') {
27+
while !out.is_char_boundary(p + 1) {
28+
p += 1;
29+
}
2730
out.drain(p + 1..);
2831
}
2932

@@ -151,4 +154,10 @@ book] or the [Reference].
151154
152155
For more information on the various types of functions and how they're used, consult the Rust book or the Reference."#]].assert_eq(&res);
153156
}
157+
158+
#[test]
159+
fn on_char_boundary() {
160+
expect!["a┘"].assert_eq(&remove_markdown("```text\na┘\n```"));
161+
expect!["وقار"].assert_eq(&remove_markdown("```\nوقار\n```\n"));
162+
}
154163
}

0 commit comments

Comments
 (0)