on master help sign in
Add helper fn for checking if opened input is theme preview file
commitcc52f79e421d8f4e18600605340cdeee7ecd6c02 authorEthan P <eth-p+git@hidden.email> dateFri 15 May 2020, 12:19 (6 years ago) parent59140b4
2 files changed+10−5
src/assets.rs+1−5 src/input.rs+9
src/assets.rs+1−5
@@ -191,11 +191,7 @@ impl HighlightingAssets {
191191 input: &mut OpenedInput,
192192 mapping: &SyntaxMapping,
193193 ) -> &SyntaxReference {
194− let syntax = if match input.kind {
195− OpenedInputKind::ThemePreviewFile => true,
196− _ => false,
197− } {
198− // FIXME: replace the above match statement with matches macro when min Rust >= 1.42.0
194+ let syntax = if input.kind.is_theme_preview_file() {
199195 self.syntax_set.find_syntax_by_name("Rust")
200196 } else if let Some(language) = language {
201197 self.syntax_set.find_syntax_by_token(language)
src/input.rs+9
@@ -39,6 +39,15 @@ pub(crate) enum OpenedInputKind {
3939 CustomReader,
4040}
4141
42+impl OpenedInputKind {
43+ pub(crate) fn is_theme_preview_file(&self) -> bool {
44+ match self {
45+ OpenedInputKind::ThemePreviewFile => true,
46+ _ => false,
47+ }
48+ }
49+}
50+
4251pub(crate) struct OpenedInput<'a> {
4352 pub(crate) kind: OpenedInputKind,
4453 pub(crate) metadata: InputMetadata,