From f84aceec3d9bc37ea4eb8bfaecefd1cb1281f6a7 Mon Sep 17 00:00:00 2001 From: sharkdp Date: Sun, 20 Sep 2020 19:54:05 +0200 Subject: [PATCH] Fix unwrap error --- src/bin/bat/main.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/bin/bat/main.rs b/src/bin/bat/main.rs index a5b6f4f9..50c39371 100644 --- a/src/bin/bat/main.rs +++ b/src/bin/bat/main.rs @@ -92,16 +92,18 @@ pub fn list_languages(config: &Config) -> Result<()> { let lang_name = lang.name.clone(); lang.file_extensions.retain(|extension| { // The 'extension' variable is not certainly a real extension. - // + // // 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' if extension.starts_with('.') || Path::new(extension).extension().is_some() { true } else { let test_file = Path::new("test").with_extension(extension); - let syntax = assets.syntax_for_file_name(test_file, &config.syntax_mapping).unwrap(); - syntax.name == lang_name + match assets.syntax_for_file_name(test_file, &config.syntax_mapping) { + Some(syntax) => syntax.name == lang_name, + None => false, + } } }); }