parse_util: fix regressions from port

Tested by the upcoming highlighting unit tests.
This commit is contained in:
Johannes Altmanninger 2023-09-17 18:02:19 +02:00
parent c7c0bb9bb2
commit 2334424234

View file

@ -52,14 +52,14 @@ pub fn parse_util_slice_length(input: &wstr) -> Option<usize> {
if !escaped {
if ['\'', '"'].contains(&c) {
pos = quote_end(input, pos, c)?;
}
} else if c == openc {
bracket_count += 1;
} else if c == closec {
bracket_count -= 1;
if bracket_count == 0 {
// pos points at the closing ], so add 1.
return Some(pos + 1);
} else if c == openc {
bracket_count += 1;
} else if c == closec {
bracket_count -= 1;
if bracket_count == 0 {
// pos points at the closing ], so add 1.
return Some(pos + 1);
}
}
}
if c == '\\' {
@ -1013,8 +1013,8 @@ pub fn parse_util_detect_errors(
if !parse_errors.is_empty() {
if let Some(errors) = out_errors.as_mut() {
errors.extend(parse_errors);
return Err(ParserTestErrorBits::ERROR);
}
return Err(ParserTestErrorBits::ERROR);
}
// Defer to the tree-walking version.