From 1eecdb0479a4f3db75efaef6d90199ac6c674f14 Mon Sep 17 00:00:00 2001 From: Dave New Date: Tue, 4 Mar 2025 14:01:45 +0200 Subject: [PATCH] fix: watcher ignore list improvements (#1751) --- cmd/program/commands.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/cmd/program/commands.go b/cmd/program/commands.go index 1df1e06d3..929967172 100644 --- a/cmd/program/commands.go +++ b/cmd/program/commands.go @@ -575,16 +575,22 @@ func StartWatcher(dir string, ch chan tea.Msg, filter []string) tea.Cmd { w.FilterOps(watcher.Write, watcher.Remove) ignored := []string{ - "node_modules/", - ".build/", - ".git/", + "node_modules", } w.AddFilterHook(func(info os.FileInfo, fullPath string) error { - for _, v := range ignored { - if strings.Contains(fullPath, v) { + // Skip if any directory component is hidden or is in the ignored list + pathParts := strings.Split(filepath.Clean(fullPath), string(filepath.Separator)) + for _, part := range pathParts { + if strings.HasPrefix(part, ".") { return watcher.ErrSkip } + + for _, v := range ignored { + if strings.Contains(part, v) { + return watcher.ErrSkip + } + } } // If there is a filter set then only watch these files