mirror of
				https://github.com/sharkdp/bat.git
				synced 2025-11-04 09:01:56 +00:00 
			
		
		
		
	Add helper fn for checking if opened input is theme preview file
This commit is contained in:
		@@ -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)
 | 
			
		||||
 
 | 
			
		||||
@@ -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,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user