Skip to content

Commit 3e6ed73

Browse files
andrewbranchCopilotCopilot
authored
Allow LSP server to use builtin watcher on Windows and macOS (#4288)
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent bb2240e commit 3e6ed73

4 files changed

Lines changed: 1499 additions & 9 deletions

File tree

internal/fswatch/watcher.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ type Watcher interface {
4848
Name() string
4949
// Available reports whether this watcher works on the current OS.
5050
Available() bool
51+
// HasFastRecursiveBackend reports whether this watcher supports efficient
52+
// recursive watching without requiring a full userspace tree walk. This is
53+
// true for Windows (ReadDirectoryChangesW subtree mode) and macOS FSEvents
54+
// (inherently recursive), and false for all other backends.
55+
HasFastRecursiveBackend() bool
5156
// WatchDirectory watches dir for changes, calling fn with batched
5257
// events. By default, only direct children are watched. Use
5358
// [WithRecursive] to watch the entire directory tree.
@@ -214,6 +219,16 @@ func (w *watcher) String() string { return w.name }
214219
func (w *watcher) Available() bool { return w.factory != nil }
215220
func (w *watcher) unexported() {}
216221

222+
// HasFastRecursiveBackend implements [Watcher.HasFastRecursiveBackend].
223+
func (w *watcher) HasFastRecursiveBackend() bool {
224+
switch w.name {
225+
case "windows", "fsevents":
226+
return true
227+
default:
228+
return false
229+
}
230+
}
231+
217232
func (w *watcher) getImpl() (watcherImpl, error) {
218233
w.mu.Lock()
219234
if w.impl != nil {

0 commit comments

Comments
 (0)