@@ -54,6 +54,7 @@ type WatchedFiles[T any] struct {
54
54
watchKind lsproto.WatchKind
55
55
computeGlobPatterns func (input T ) patternsAndIgnored
56
56
57
+ mu sync.RWMutex
57
58
input T
58
59
computeWatchersOnce sync.Once
59
60
watchers []* lsproto.FileSystemWatcher
@@ -70,8 +71,10 @@ func NewWatchedFiles[T any](name string, watchKind lsproto.WatchKind, computeGlo
70
71
}
71
72
}
72
73
73
- func (w * WatchedFiles [T ]) Watchers () (WatcherID , []* lsproto.FileSystemWatcher ) {
74
+ func (w * WatchedFiles [T ]) Watchers () (WatcherID , []* lsproto.FileSystemWatcher , map [ string ] struct {} ) {
74
75
w .computeWatchersOnce .Do (func () {
76
+ w .mu .Lock ()
77
+ defer w .mu .Unlock ()
75
78
result := w .computeGlobPatterns (w .input )
76
79
globs := result .patterns
77
80
ignored := result .ignored
@@ -91,7 +94,10 @@ func (w *WatchedFiles[T]) Watchers() (WatcherID, []*lsproto.FileSystemWatcher) {
91
94
w .id = watcherID .Add (1 )
92
95
}
93
96
})
94
- return WatcherID (fmt .Sprintf ("%s watcher %d" , w .name , w .id )), w .watchers
97
+
98
+ w .mu .RLock ()
99
+ defer w .mu .RUnlock ()
100
+ return WatcherID (fmt .Sprintf ("%s watcher %d" , w .name , w .id )), w .watchers , w .ignored
95
101
}
96
102
97
103
func (w * WatchedFiles [T ]) ID () WatcherID {
@@ -111,6 +117,8 @@ func (w *WatchedFiles[T]) WatchKind() lsproto.WatchKind {
111
117
}
112
118
113
119
func (w * WatchedFiles [T ]) Clone (input T ) * WatchedFiles [T ] {
120
+ w .mu .RLock ()
121
+ defer w .mu .RUnlock ()
114
122
return & WatchedFiles [T ]{
115
123
name : w .name ,
116
124
watchKind : w .watchKind ,
0 commit comments