diff --git a/internal/project/configfileregistry.go b/internal/project/configfileregistry.go index e17a52bdf6..26b9060ba9 100644 --- a/internal/project/configfileregistry.go +++ b/internal/project/configfileregistry.go @@ -239,7 +239,10 @@ func (c *ConfigFileRegistry) tryInvokeWildCardDirectories(fileName string, path configFiles := c.ConfigFiles.ToMap() for configPath, entry := range configFiles { entry.mu.Lock() - hasSet := entry.commandLine != nil && entry.commandLine.MatchesFileName(fileName) && entry.SetPendingReload(PendingReloadFileNames) + hasSet := false + if entry.commandLine != nil && entry.pendingReload == PendingReloadNone && entry.commandLine.MatchesFileName(fileName) { + hasSet = entry.SetPendingReload(PendingReloadFileNames) + } var projects map[*Project]struct{} if hasSet { projects = maps.Clone(entry.projects.Keys()) diff --git a/internal/project/service.go b/internal/project/service.go index b4a5249cd1..0759a7f3a1 100644 --- a/internal/project/service.go +++ b/internal/project/service.go @@ -9,6 +9,7 @@ import ( "strings" "sync" + "github.com/microsoft/typescript-go/internal/collections" "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/ls" "github.com/microsoft/typescript-go/internal/lsp/lsproto" @@ -296,9 +297,15 @@ func (s *Service) Close() { } func (s *Service) OnWatchedFilesChanged(ctx context.Context, changes []*lsproto.FileEvent) error { + seen := collections.NewSetWithSizeHint[lsproto.FileEvent](len(changes)) + s.projectsMu.RLock() defer s.projectsMu.RUnlock() for _, change := range changes { + if !seen.AddIfAbsent(*change) { + continue + } + fileName := ls.DocumentURIToFileName(change.Uri) path := s.toPath(fileName) if err, ok := s.configFileRegistry.onWatchedFilesChanged(path, change.Type); ok {