Skip to content

Skip more work when creating LSP watch globs #1015

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

Merged
merged 1 commit into from
Jun 2, 2025
Merged
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
9 changes: 9 additions & 0 deletions internal/project/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"strings"
"time"

"github.com/microsoft/typescript-go/internal/core"
"github.com/microsoft/typescript-go/internal/lsp/lsproto"
"github.com/microsoft/typescript-go/internal/tspath"
)
Expand Down Expand Up @@ -101,8 +102,16 @@ func createResolutionLookupGlobMapper(host ProjectHost) func(data map[tspath.Pat

// dir -> recursive
globSet := make(map[string]bool)
var seenDirs core.Set[string]

for path, fileName := range data {
// Assuming all of the input paths are filenames, we can avoid
// duplicate work by only taking one file per dir, since their outputs
// will always be the same.
if !seenDirs.AddIfAbsent(tspath.GetDirectoryPath(string(path))) {
continue
}

w := getDirectoryToWatchFailedLookupLocation(
fileName,
path,
Expand Down