mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 22:50:14 +02:00
Merge pull request #1126 from jonathandturner/utf8_fix
UTF8 fix for twitter-reported issue
This commit is contained in:
@ -357,7 +357,10 @@ fn word<'a, T, U, V>(
|
||||
|
||||
pub fn matches(cond: fn(char) -> bool) -> impl Fn(NomSpan) -> IResult<NomSpan, NomSpan> + Copy {
|
||||
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(
|
||||
input,
|
||||
nom::error::ErrorKind::Many0,
|
||||
|
Reference in New Issue
Block a user