mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
Auto merge of #16155 - Waqar144:work/fix-16142, r=lnicola
fix: Dont assume ascii in remove_markdown Fixes #16142
This commit is contained in:
commit
dbd0b035e6
1 changed files with 10 additions and 1 deletions
|
@ -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..);
|
out.drain(p + 1..);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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);
|
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"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue