diff options
| author | bors <bors@rust-lang.org> | 2023-12-19 07:22:46 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-12-19 07:22:46 +0000 |
| commit | dbd0b035e642ae55c35ad3fffa5507cf42fc8d8e (patch) | |
| tree | 659a4aeb19526f3c22990b06e4478fb9dd22dd71 | |
| parent | 1c4c2200eb26e456c86ebce5535b8f152e2e2ec0 (diff) | |
| parent | 5318e89b8a77de72d478be13d7ae0eea3f397629 (diff) | |
| download | rust-dbd0b035e642ae55c35ad3fffa5507cf42fc8d8e.tar.gz rust-dbd0b035e642ae55c35ad3fffa5507cf42fc8d8e.zip | |
Auto merge of #16155 - Waqar144:work/fix-16142, r=lnicola
fix: Dont assume ascii in remove_markdown Fixes #16142
| -rw-r--r-- | crates/ide/src/markdown_remove.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/crates/ide/src/markdown_remove.rs b/crates/ide/src/markdown_remove.rs index 9d3e6882def..fa01875e204 100644 --- a/crates/ide/src/markdown_remove.rs +++ b/crates/ide/src/markdown_remove.rs @@ -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..); } @@ -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")); + } } |
