diff --git a/src/parser/org_source.rs b/src/parser/org_source.rs index 87f93da..820c01c 100644 --- a/src/parser/org_source.rs +++ b/src/parser/org_source.rs @@ -145,6 +145,9 @@ where if new_end > self.end { panic!("Attempted to extend past the end of the WrappedInput.") } + if new_start == self.start && new_end == self.end { + return self.clone(); + } let skipped_text = &self.full_source[self.start..new_start]; let mut start_of_line = self.start_of_line; @@ -183,7 +186,7 @@ where start: new_start, end: new_end, start_of_line, - preceding_character: skipped_text.chars().last(), + preceding_character: skipped_text.chars().last().or(self.preceding_character), bracket_depth, brace_depth, parenthesis_depth, diff --git a/src/parser/util.rs b/src/parser/util.rs index 6464fe8..6625b86 100644 --- a/src/parser/util.rs +++ b/src/parser/util.rs @@ -153,7 +153,7 @@ fn _preceded_by_whitespace<'s>( .unwrap_or(allow_start_of_file) { return Err(nom::Err::Error(CustomError::MyError(MyError( - "Must be preceded by a non-whitespace character.".into(), + "Must be preceded by a whitespace character.".into(), )))); } Ok((input, ()))