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

src/printer.rs: Simplify Plain Text fallback code

By forwarding the task to find the `Plain Text` syntax to `assets`. Not only does
the code become simpler; we also get rid of a call to `self.get_syntax_set()`
which is beneficial to the long term goal of replacing `syntaxes.bin` with
`minimal_syntaxes.bin`.

Note that the use of `.expect()` is not a regression in error handling. It was
previously hidden in `.find_syntax_plain_text()`.
This commit is contained in:
Martin Nordholts
2021-09-27 20:09:26 +02:00
parent 405a80f3ee
commit aefc8fd824
2 changed files with 7 additions and 6 deletions

View File

@@ -245,7 +245,10 @@ impl HighlightingAssets {
}
}
fn find_syntax_by_name(&self, syntax_name: &str) -> Result<Option<SyntaxReferenceInSet>> {
pub(crate) fn find_syntax_by_name(
&self,
syntax_name: &str,
) -> Result<Option<SyntaxReferenceInSet>> {
let syntax_set = self.get_syntax_set()?;
Ok(syntax_set
.find_syntax_by_name(syntax_name)