Skip to content

Commit

Permalink
Auto merge of #16155 - Waqar144:work/fix-16142, r=lnicola
Browse files Browse the repository at this point in the history
fix: Dont assume ascii in remove_markdown

Fixes #16142
  • Loading branch information
bors committed Dec 19, 2023
2 parents 1c4c220 + 5318e89 commit dbd0b03
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion crates/ide/src/markdown_remove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ pub(crate) fn remove_markdown(markdown: &str) -> String {
}
}

if let Some(p) = out.rfind(|c| c != '\n') {
if let Some(mut p) = out.rfind(|c| c != '\n') {
while !out.is_char_boundary(p + 1) {
p += 1;
}
out.drain(p + 1..);
}

Expand Down Expand Up @@ -151,4 +154,10 @@ book] or the [Reference].
For more information on the various types of functions and how they're used, consult the Rust book or the Reference."#]].assert_eq(&res);
}

#[test]
fn on_char_boundary() {
expect!["a┘"].assert_eq(&remove_markdown("```text\na┘\n```"));
expect!["وقار"].assert_eq(&remove_markdown("```\nوقار\n```\n"));
}
}

0 comments on commit dbd0b03

Please sign in to comment.