Iterate over the bytes instead of characters when counting brackets.
This commit is contained in:
parent
c683516620
commit
288350daef
@ -19,8 +19,8 @@ pub struct OrgSource<'s> {
|
|||||||
start_of_line: usize,
|
start_of_line: usize,
|
||||||
preceding_character: Option<char>,
|
preceding_character: Option<char>,
|
||||||
line_number: usize,
|
line_number: usize,
|
||||||
bracket_depth: isize, // []
|
bracket_depth: isize, // []
|
||||||
brace_depth: isize, // {}
|
brace_depth: isize, // {}
|
||||||
parenthesis_depth: isize, // ()
|
parenthesis_depth: isize, // ()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,28 +148,28 @@ where
|
|||||||
let mut bracket_depth = self.bracket_depth;
|
let mut bracket_depth = self.bracket_depth;
|
||||||
let mut brace_depth = self.brace_depth;
|
let mut brace_depth = self.brace_depth;
|
||||||
let mut parenthesis_depth = self.parenthesis_depth;
|
let mut parenthesis_depth = self.parenthesis_depth;
|
||||||
for (offset, character) in skipped_text.char_indices() {
|
for (offset, byte) in skipped_text.bytes().enumerate() {
|
||||||
match character {
|
match byte {
|
||||||
'\n' => {
|
b'\n' => {
|
||||||
start_of_line = self.start + offset + 1;
|
start_of_line = self.start + offset + 1;
|
||||||
line_number += 1;
|
line_number += 1;
|
||||||
}
|
}
|
||||||
'[' => {
|
b'[' => {
|
||||||
bracket_depth += 1;
|
bracket_depth += 1;
|
||||||
}
|
}
|
||||||
']' => {
|
b']' => {
|
||||||
bracket_depth -= 1;
|
bracket_depth -= 1;
|
||||||
}
|
}
|
||||||
'{' => {
|
b'{' => {
|
||||||
brace_depth += 1;
|
brace_depth += 1;
|
||||||
}
|
}
|
||||||
'}' => {
|
b'}' => {
|
||||||
brace_depth -= 1;
|
brace_depth -= 1;
|
||||||
}
|
}
|
||||||
'(' => {
|
b'(' => {
|
||||||
parenthesis_depth += 1;
|
parenthesis_depth += 1;
|
||||||
}
|
}
|
||||||
')' => {
|
b')' => {
|
||||||
parenthesis_depth -= 1;
|
parenthesis_depth -= 1;
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
Loading…
Reference in New Issue
Block a user