Support zero skipped text in OrgSource slicing.

This commit is contained in:
Tom Alexander 2023-09-07 04:15:17 -04:00
parent 69512f559a
commit b0930df788
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
2 changed files with 5 additions and 2 deletions

View File

@ -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,

View File

@ -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, ()))