From 70cc0fdadf1e2d9845083e62364c3c7dd0e8a670 Mon Sep 17 00:00:00 2001 From: Chrystian Date: Wed, 25 Sep 2024 21:52:00 -0300 Subject: [PATCH] fix: Ignore directories when rebuilding cache if they do not exist. (#249) --- src/assets.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/assets.rs b/src/assets.rs index 6cae6ba..e167d46 100644 --- a/src/assets.rs +++ b/src/assets.rs @@ -38,10 +38,16 @@ impl HighlightingAssets { pub fn add_from_folder>(&mut self, path: P) -> Result<()> { let path = path.as_ref(); - self.theme_set.add_from_folder(path.join("themes"))?; + let theme_dir = path.join("themes"); + if theme_dir.is_dir() { + self.theme_set.add_from_folder(theme_dir)?; + } let mut builder = self.syntax_set.clone().into_builder(); - builder.add_from_folder(path.join("syntaxes"), true)?; - self.syntax_set = builder.build(); + let syntaxes_dir = path.join("syntaxes"); + if syntaxes_dir.is_dir() { + builder.add_from_folder(syntaxes_dir, true)?; + self.syntax_set = builder.build(); + } Ok(()) }