Skip to content

Fix glob pattern file watcher handling #55

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions internal/watcher/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -456,27 +456,6 @@ func (w *WorkspaceWatcher) matchesPattern(path string, pattern protocol.GlobPatt

path = filepath.ToSlash(path)

// Special handling for wildcard patterns like "**/*"
if patternText == "**/*" {
// This should match any file
// watcherLogger.Debug("Using special matching for **/* pattern")
return true
}

// Special handling for wildcard patterns like "**/*.ext"
if strings.HasPrefix(patternText, "**/") {
if strings.HasPrefix(strings.TrimPrefix(patternText, "**/"), "*.") {
// Extension pattern like **/*.go
ext := strings.TrimPrefix(strings.TrimPrefix(patternText, "**/"), "*")
// watcherLogger.Debug("Using extension matching for **/*.ext pattern: checking if %s ends with %s", path, ext)
return strings.HasSuffix(path, ext)
} else {
// Any other pattern starting with **/ should match any path
// watcherLogger.Debug("Using path substring matching for **/ pattern")
return true
}
}

// For simple patterns without base path
if basePath == "" {
// Check if the pattern matches the full path or just the file extension
Expand Down