Fix multibyte codepoint crash (#1243)
Co-authored-by: Evan Richter <evanjrichter@gmail.com>
This commit is contained in:
parent
691b3dcf56
commit
c625d61abd
@ -5,7 +5,7 @@ pub fn unindent(text: &str) -> String {
|
|||||||
let mut start = 0;
|
let mut start = 0;
|
||||||
for (i, c) in text.char_indices() {
|
for (i, c) in text.char_indices() {
|
||||||
if c == '\n' || i == text.len() - c.len_utf8() {
|
if c == '\n' || i == text.len() - c.len_utf8() {
|
||||||
let end = i + 1;
|
let end = i + c.len_utf8();
|
||||||
lines.push(&text[start..end]);
|
lines.push(&text[start..end]);
|
||||||
start = end;
|
start = end;
|
||||||
}
|
}
|
||||||
|
@ -57,6 +57,7 @@ mod invocation_directory;
|
|||||||
mod json;
|
mod json;
|
||||||
mod line_prefixes;
|
mod line_prefixes;
|
||||||
mod misc;
|
mod misc;
|
||||||
|
mod multibyte_char;
|
||||||
mod positional_arguments;
|
mod positional_arguments;
|
||||||
mod quiet;
|
mod quiet;
|
||||||
mod quote;
|
mod quote;
|
||||||
|
6
tests/multibyte_char.rs
Normal file
6
tests/multibyte_char.rs
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn bugfix() {
|
||||||
|
Test::new().justfile("foo:\nx := '''ǩ'''").run();
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user