From cc52f79e421d8f4e18600605340cdeee7ecd6c02 Mon Sep 17 00:00:00 2001 From: Ethan P Date: Fri, 15 May 2020 12:19:11 -0700 Subject: [PATCH] Add helper fn for checking if opened input is theme preview file --- src/assets.rs | 6 +----- src/input.rs | 9 +++++++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/assets.rs b/src/assets.rs index 0448df09..7a3cc81f 100644 --- a/src/assets.rs +++ b/src/assets.rs @@ -191,11 +191,7 @@ impl HighlightingAssets { input: &mut OpenedInput, mapping: &SyntaxMapping, ) -> &SyntaxReference { - let syntax = if match input.kind { - OpenedInputKind::ThemePreviewFile => true, - _ => false, - } { - // FIXME: replace the above match statement with matches macro when min Rust >= 1.42.0 + let syntax = if input.kind.is_theme_preview_file() { self.syntax_set.find_syntax_by_name("Rust") } else if let Some(language) = language { self.syntax_set.find_syntax_by_token(language) diff --git a/src/input.rs b/src/input.rs index 929a6524..eeb9a494 100644 --- a/src/input.rs +++ b/src/input.rs @@ -39,6 +39,15 @@ pub(crate) enum OpenedInputKind { CustomReader, } +impl OpenedInputKind { + pub(crate) fn is_theme_preview_file(&self) -> bool { + match self { + OpenedInputKind::ThemePreviewFile => true, + _ => false, + } + } +} + pub(crate) struct OpenedInput<'a> { pub(crate) kind: OpenedInputKind, pub(crate) metadata: InputMetadata,