mirror of
https://github.com/ankitects/anki.git
synced 2025-12-10 21:36:55 -05:00
handle trailing whitespace inside group
This commit is contained in:
parent
25ff4642ec
commit
430f1ad616
1 changed files with 13 additions and 0 deletions
|
|
@ -162,6 +162,9 @@ fn group_inner(input: &str) -> IResult<&str, Vec<Node>> {
|
||||||
if nodes.is_empty() {
|
if nodes.is_empty() {
|
||||||
Err(nom::Err::Error((remaining, nom::error::ErrorKind::Many1)))
|
Err(nom::Err::Error((remaining, nom::error::ErrorKind::Many1)))
|
||||||
} else {
|
} else {
|
||||||
|
// chomp any trailing whitespace
|
||||||
|
let (remaining, _) = whitespace0(remaining)?;
|
||||||
|
|
||||||
Ok((remaining, nodes))
|
Ok((remaining, nodes))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -428,6 +431,16 @@ mod test {
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// including in groups
|
||||||
|
assert_eq!(
|
||||||
|
parse("( t t2 )")?,
|
||||||
|
vec![Group(vec![
|
||||||
|
Search(UnqualifiedText("t".into())),
|
||||||
|
And,
|
||||||
|
Search(UnqualifiedText("t2".into()))
|
||||||
|
])]
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
parse(r#"hello -(world and "foo:bar baz") OR test"#)?,
|
parse(r#"hello -(world and "foo:bar baz") OR test"#)?,
|
||||||
vec![
|
vec![
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue