diff options
author | Martin Nordholts <enselic@gmail.com> | 2021-09-27 20:09:26 +0200 |
---|---|---|
committer | Martin Nordholts <enselic@gmail.com> | 2021-09-29 17:54:45 +0200 |
commit | aefc8fd8243b8270849aeecee7dc443210cd9b3b (patch) | |
tree | b670a8d11f4037a926a649e6911988c7c13d922c /src/assets.rs | |
parent | 405a80f3eeab25870249943ceb4f209e6599eca1 (diff) |
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()`.
Diffstat (limited to 'src/assets.rs')
-rw-r--r-- | src/assets.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/assets.rs b/src/assets.rs index 1c820d6c..5b35d803 100644 --- a/src/assets.rs +++ b/src/assets.rs @@ -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) |