mirror of
				https://github.com/sharkdp/bat.git
				synced 2025-11-04 09:01:56 +00:00 
			
		
		
		
	Fix unwrap error
This commit is contained in:
		@@ -92,16 +92,18 @@ pub fn list_languages(config: &Config) -> Result<()> {
 | 
				
			|||||||
        let lang_name = lang.name.clone();
 | 
					        let lang_name = lang.name.clone();
 | 
				
			||||||
        lang.file_extensions.retain(|extension| {
 | 
					        lang.file_extensions.retain(|extension| {
 | 
				
			||||||
            // The 'extension' variable is not certainly a real extension.
 | 
					            // The 'extension' variable is not certainly a real extension.
 | 
				
			||||||
            // 
 | 
					            //
 | 
				
			||||||
            // Skip if 'extension' starts with '.', likely a hidden file like '.vimrc'
 | 
					            // Skip if 'extension' starts with '.', likely a hidden file like '.vimrc'
 | 
				
			||||||
            // Also skip if the 'extension' contains another real extension, likely 
 | 
					            // Also skip if the 'extension' contains another real extension, likely
 | 
				
			||||||
            // that is a full match file name like 'CMakeLists.txt' and 'Cargo.lock'
 | 
					            // that is a full match file name like 'CMakeLists.txt' and 'Cargo.lock'
 | 
				
			||||||
            if extension.starts_with('.') || Path::new(extension).extension().is_some() {
 | 
					            if extension.starts_with('.') || Path::new(extension).extension().is_some() {
 | 
				
			||||||
                true
 | 
					                true
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                let test_file = Path::new("test").with_extension(extension);
 | 
					                let test_file = Path::new("test").with_extension(extension);
 | 
				
			||||||
                let syntax = assets.syntax_for_file_name(test_file, &config.syntax_mapping).unwrap();
 | 
					                match assets.syntax_for_file_name(test_file, &config.syntax_mapping) {
 | 
				
			||||||
                syntax.name == lang_name
 | 
					                    Some(syntax) => syntax.name == lang_name,
 | 
				
			||||||
 | 
					                    None => false,
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user