Skip to content

Commit fc75e42

Browse files
committed
Forgot to use PossiblyMatchesFileName and delete watcher parsed globs
1 parent be4e57f commit fc75e42

File tree

2 files changed

+7
-29
lines changed

2 files changed

+7
-29
lines changed

internal/project/configfileregistrybuilder.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -387,11 +387,8 @@ func (c *configFileRegistryBuilder) DidChangeFiles(summary FileChangeSummary, lo
387387
}
388388
logger.Logf("Checking if any of %d created files match root files for config %s", len(createdFiles), entry.Key())
389389
for _, fileName := range createdFiles {
390-
parsedGlobs := config.commandLine.WildcardDirectoryGlobs()
391-
for _, g := range parsedGlobs {
392-
if g.Match(fileName) {
393-
return true
394-
}
390+
if config.commandLine.PossiblyMatchesFileName(fileName) {
391+
return true
395392
}
396393
}
397394
return false

internal/project/watch.go

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"github.com/microsoft/typescript-go/internal/ast"
1111
"github.com/microsoft/typescript-go/internal/collections"
1212
"github.com/microsoft/typescript-go/internal/core"
13-
"github.com/microsoft/typescript-go/internal/glob"
1413
"github.com/microsoft/typescript-go/internal/lsp/lsproto"
1514
"github.com/microsoft/typescript-go/internal/module"
1615
"github.com/microsoft/typescript-go/internal/tspath"
@@ -55,13 +54,11 @@ type WatchedFiles[T any] struct {
5554
watchKind lsproto.WatchKind
5655
computeGlobPatterns func(input T) patternsAndIgnored
5756

58-
input T
59-
computeWatchersOnce sync.Once
60-
watchers []*lsproto.FileSystemWatcher
61-
ignored map[string]struct{}
62-
computeParsedGlobsOnce sync.Once
63-
parsedGlobs []*glob.Glob
64-
id uint64
57+
input T
58+
computeWatchersOnce sync.Once
59+
watchers []*lsproto.FileSystemWatcher
60+
ignored map[string]struct{}
61+
id uint64
6562
}
6663

6764
func NewWatchedFiles[T any](name string, watchKind lsproto.WatchKind, computeGlobPatterns func(input T) patternsAndIgnored) *WatchedFiles[T] {
@@ -113,29 +110,13 @@ func (w *WatchedFiles[T]) WatchKind() lsproto.WatchKind {
113110
return w.watchKind
114111
}
115112

116-
func (w *WatchedFiles[T]) ParsedGlobs() []*glob.Glob {
117-
w.computeParsedGlobsOnce.Do(func() {
118-
_, watchers := w.Watchers()
119-
w.parsedGlobs = make([]*glob.Glob, 0, len(watchers))
120-
for _, watcher := range watchers {
121-
if g, err := glob.Parse(*watcher.GlobPattern.Pattern); err == nil {
122-
w.parsedGlobs = append(w.parsedGlobs, g)
123-
} else {
124-
panic("failed to parse glob pattern: " + *watcher.GlobPattern.Pattern)
125-
}
126-
}
127-
})
128-
return w.parsedGlobs
129-
}
130-
131113
func (w *WatchedFiles[T]) Clone(input T) *WatchedFiles[T] {
132114
return &WatchedFiles[T]{
133115
name: w.name,
134116
watchKind: w.watchKind,
135117
computeGlobPatterns: w.computeGlobPatterns,
136118
watchers: w.watchers,
137119
input: input,
138-
parsedGlobs: w.parsedGlobs,
139120
}
140121
}
141122

0 commit comments

Comments
 (0)