improvement on parsing accuracy for case patterns

This commit is contained in:
2026-03-04 18:27:40 -05:00
parent 3c70c9dace
commit b831bdf166
3 changed files with 21 additions and 493 deletions

View File

@@ -1087,11 +1087,26 @@ pub fn case_pat_lookahead(mut chars: Peekable<Chars>) -> Option<usize> {
while let Some(ch) = chars.next() {
pos += ch.len_utf8();
match ch {
_ if is_hard_sep(ch) => return None,
_ if qt_state.outside() && is_hard_sep(ch) => return None,
'\\' => {
if let Some(esc) = chars.next() {
pos += esc.len_utf8();
}
}
'$' if qt_state.outside() && chars.peek() == Some(&'\'') => {
// $'...' ANSI-C quoting — skip through to closing quote
chars.next(); // consume opening '
pos += 1;
while let Some(c) = chars.next() {
pos += c.len_utf8();
if c == '\\' {
if let Some(esc) = chars.next() {
pos += esc.len_utf8();
}
} else if c == '\'' {
break;
}
}
}
'\'' => {
qt_state.toggle_single();