1
0
mirror of https://github.com/sharkdp/bat.git synced 2025-09-15 01:32:25 +01:00

HighlightingAssets: Encapsulate syntax_set behind a getter

Since we only modify `pub(crate)` items, the stable bat-as-a-library API is not
affected.

This takes us one step closer to making SyntaxSet lazy-loaded, which in turn
takes us one step closer to solving #951.
This commit is contained in:
Martin Nordholts
2021-07-16 11:49:47 +02:00
parent 6ef2bb3283
commit 375d55aa5d
2 changed files with 19 additions and 15 deletions

View File

@@ -174,7 +174,7 @@ impl<'a> InteractivePrinter<'a> {
let syntax = match assets.get_syntax(config.language, input, &config.syntax_mapping) {
Ok(syntax) => syntax,
Err(Error(ErrorKind::UndetectedSyntax(_), _)) => {
assets.syntax_set.find_syntax_plain_text()
assets.get_syntax_set().find_syntax_plain_text()
}
Err(e) => return Err(e),
};
@@ -192,7 +192,7 @@ impl<'a> InteractivePrinter<'a> {
#[cfg(feature = "git")]
line_changes,
highlighter,
syntax_set: &assets.syntax_set,
syntax_set: assets.get_syntax_set(),
background_color_highlight,
})
}