Update getting the previous character and previous line.

This can be done a lot more efficiently now that we are keeping track of this information in the wrapped input type instead of having to fetch to the original document out of the context tree.
This commit is contained in:
Tom Alexander
2023-08-24 16:55:56 -04:00
parent dab598e5e7
commit 720afa5d32
9 changed files with 59 additions and 114 deletions

View File

@@ -21,7 +21,6 @@ use crate::parser::parser_context::ExitMatcherNode;
use crate::parser::parser_with_context::parser_with_context;
use crate::parser::util::exit_matcher_parser;
use crate::parser::util::get_consumed;
use crate::parser::util::get_one_before;
use crate::parser::util::WORD_CONSTITUENT_CHARACTERS;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
@@ -47,10 +46,7 @@ pub fn plain_link<'r, 's>(
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn pre<'r, 's>(context: Context<'r, 's>, input: OrgSource<'s>) -> Res<OrgSource<'s>, ()> {
let document_root = context.get_document_root().unwrap();
let preceding_character = get_one_before(document_root, input)
.map(|slice| slice.chars().next())
.flatten();
let preceding_character = input.get_preceding_character();
match preceding_character {
// If None, we are at the start of the file which is fine
None => {}