From 05e9da390fbb9a595b15df4860f61efde81ea9d2 Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Mon, 28 Dec 2020 10:34:31 +0100 Subject: [PATCH 1/2] bat cache --build: Print syntect error message for themes if any This will fix #614 by making it clear what is wrong by showing the following error message: Failed to load one or more themes from '/Users/me/.config/bat/themes' (reason: 'Invalid syntax theme settings') We also need to add a check if theme_dir.exists(), otherwise an absent dir will seem like an error: Failed to load one or more themes from '/Users/me/.config/bat/themes' (reason: 'IO error for operation on /Users/me/.config/bat/themes: No such file or directory (os error 2)') (This is the same check we already have for syntax_dir.) --- src/assets.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/assets.rs b/src/assets.rs index 5e0c0644..55b4941e 100644 --- a/src/assets.rs +++ b/src/assets.rs @@ -38,9 +38,16 @@ impl HighlightingAssets { }; let theme_dir = source_dir.join("themes"); - - let res = theme_set.add_from_folder(&theme_dir); - if res.is_err() { + if theme_dir.exists() { + let res = theme_set.add_from_folder(&theme_dir); + if let Err(err) = res { + println!( + "Failed to load one or more themes from '{}' (reason: '{}')", + theme_dir.to_string_lossy(), + err, + ); + } + } else { println!( "No themes were found in '{}', using the default set", theme_dir.to_string_lossy() From f45fa5e18718140a0892e4e662c8715e1f1a073c Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Mon, 28 Dec 2020 10:55:20 +0100 Subject: [PATCH 2/2] CHANGELOG.md: Add bugfix entry for #614 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e0fb4ae2..43ef8493 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - Only print themes hint in interactive mode (`bat --list-themes`), see #1439 (@rsteube) - Make ./tests/syntax-tests/regression_test.sh work on recent versions of macOS, see #1443 (@Enselic) - VimL syntax highlighting fix, see #1450 (@esensar) +- Print an 'Invalid syntax theme settings' error message if a custom theme is broken, see #614 (@Enselic) ## Other