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:
@@ -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)
|
||||
|
Reference in New Issue
Block a user