mirror of
https://github.com/nushell/nushell
synced 2024-12-26 04:53:09 +00:00
UTF8 fix for twitter-reported issue
This commit is contained in:
parent
e7ce6f2fcd
commit
68a314b5cb
2 changed files with 19 additions and 1 deletions
|
@ -357,7 +357,10 @@ fn word<'a, T, U, V>(
|
||||||
|
|
||||||
pub fn matches(cond: fn(char) -> bool) -> impl Fn(NomSpan) -> IResult<NomSpan, NomSpan> + Copy {
|
pub fn matches(cond: fn(char) -> bool) -> impl Fn(NomSpan) -> IResult<NomSpan, NomSpan> + Copy {
|
||||||
move |input: NomSpan| match input.iter_elements().next() {
|
move |input: NomSpan| match input.iter_elements().next() {
|
||||||
Option::Some(c) if cond(c) => Ok((input.slice(1..), input.slice(0..1))),
|
Option::Some(c) if cond(c) => {
|
||||||
|
let len_utf8 = c.len_utf8();
|
||||||
|
Ok((input.slice(len_utf8..), input.slice(0..len_utf8)))
|
||||||
|
}
|
||||||
_ => Err(nom::Err::Error(nom::error::ParseError::from_error_kind(
|
_ => Err(nom::Err::Error(nom::error::ParseError::from_error_kind(
|
||||||
input,
|
input,
|
||||||
nom::error::ErrorKind::Many0,
|
nom::error::ErrorKind::Many0,
|
||||||
|
|
|
@ -29,6 +29,21 @@ mod pipeline {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn doesnt_break_on_utf8_command() {
|
||||||
|
let actual = nu!(
|
||||||
|
cwd: std::path::PathBuf::from("."),
|
||||||
|
r#"
|
||||||
|
sh -c "echo ö"
|
||||||
|
"#
|
||||||
|
);
|
||||||
|
|
||||||
|
assert!(
|
||||||
|
actual.contains("ö"),
|
||||||
|
format!("'{}' should contain ö", actual)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn can_process_row_as_it_argument_to_an_external_command_given_the_it_data_is_one_string_line()
|
fn can_process_row_as_it_argument_to_an_external_command_given_the_it_data_is_one_string_line()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue