From 0576a2fe9f4e46eb42349989cfcf41b8dc1024e2 Mon Sep 17 00:00:00 2001 From: aodenis <45949528+aodenis@users.noreply.github.com> Date: Sat, 22 Feb 2025 00:26:26 +0100 Subject: [PATCH] Increase code readability --- crates/typst-cli/src/watch.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/crates/typst-cli/src/watch.rs b/crates/typst-cli/src/watch.rs index 97eb07d0f..bc2fdc165 100644 --- a/crates/typst-cli/src/watch.rs +++ b/crates/typst-cli/src/watch.rs @@ -237,7 +237,7 @@ impl Watcher { /// Whether a watch event is relevant for compilation. fn is_event_relevant(&self, event: ¬ify::Event) -> bool { - let type_relevant = match &event.kind { + let kind_relevant = match &event.kind { notify::EventKind::Any => true, notify::EventKind::Access(_) => false, notify::EventKind::Create(_) => true, @@ -252,12 +252,20 @@ impl Watcher { notify::EventKind::Other => false, }; + if !kind_relevant { + return false; + } + // Never recompile because the output file changed. - type_relevant - && !event - .paths - .iter() - .all(|path| is_same_file(path, &self.output).unwrap_or(false)) + if event + .paths + .iter() + .all(|path| is_same_file(path, &self.output).unwrap_or(false)) + { + return false; + } + + true } }