Remove line number tracking.

The documentation was incorrect, none of the org-mode elements have a line number restriction for their contents.
This commit is contained in:
Tom Alexander 2023-08-29 11:09:28 -04:00
parent bd97d2f69d
commit 8051c3d2b7
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

View File

@ -18,7 +18,6 @@ pub struct OrgSource<'s> {
end: usize, // exclusive
start_of_line: usize,
preceding_character: Option<char>,
line_number: usize,
bracket_depth: i32, // []
brace_depth: i32, // {}
parenthesis_depth: i32, // ()
@ -43,7 +42,6 @@ impl<'s> OrgSource<'s> {
end: input.len(),
start_of_line: 0,
preceding_character: None,
line_number: 1,
bracket_depth: 0,
brace_depth: 0,
parenthesis_depth: 0,
@ -73,10 +71,6 @@ impl<'s> OrgSource<'s> {
self.slice(..(other.start - self.start))
}
pub fn get_line_number(&self) -> usize {
self.line_number
}
pub fn get_bracket_depth(&self) -> i32 {
self.bracket_depth
}
@ -152,7 +146,6 @@ where
let skipped_text = &self.full_source[self.start..new_start];
let mut start_of_line = self.start_of_line;
let mut line_number = self.line_number;
let mut bracket_depth = self.bracket_depth;
let mut brace_depth = self.brace_depth;
let mut parenthesis_depth = self.parenthesis_depth;
@ -160,7 +153,6 @@ where
match byte {
b'\n' => {
start_of_line = self.start + offset + 1;
line_number += 1;
}
b'[' => {
bracket_depth += 1;
@ -190,7 +182,6 @@ where
end: new_end,
start_of_line,
preceding_character: skipped_text.chars().last(),
line_number,
bracket_depth,
brace_depth,
parenthesis_depth,
@ -436,15 +427,6 @@ mod tests {
assert_eq!(input.slice(8..).get_preceding_character(), Some('💛'));
}
#[test]
fn line_number() {
let input = OrgSource::new("lorem\nfoo\nbar\nbaz\nipsum");
assert_eq!(input.get_line_number(), 1);
assert_eq!(input.slice(5..).get_line_number(), 1);
assert_eq!(input.slice(6..).get_line_number(), 2);
assert_eq!(input.slice(6..).slice(10..).get_line_number(), 4);
}
#[test]
fn depth() {
let input = OrgSource::new("[][()][({)]}}}}");