Correct delimiter positions

j counts from 0, so add the start value. Also ensure it is never equal
to i, or we get confused by delimiters where the open and close tokens
are the same (such as `|foo|` in Rust).
pull/41/head
Wilfred Hughes 2021-09-26 21:40:10 +07:00
parent 8a145e7b76
commit b0b1579f26
1 changed files with 2 additions and 2 deletions

@ -287,9 +287,9 @@ fn find_delim_positions(
for (i, token) in tokens.iter().enumerate() {
for (open_delim, close_delim) in lang_delims {
if *token == Some(open_delim) {
for (j, token) in tokens.iter().skip(i).enumerate() {
for (j, token) in tokens.iter().skip(i + 1).enumerate() {
if *token == Some(close_delim) {
return Some((i, j));
return Some((i, i + 1 + j));
}
}
}