mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-14 12:34:44 +02:00
Use a single go routine to watch all dirs
This commit is contained in:
@@ -22,11 +22,14 @@ import (
|
|||||||
var _ = fmt.Print
|
var _ = fmt.Print
|
||||||
|
|
||||||
// watch_dir starts fswatcher in a background goroutine and pipes events to a custom channel.
|
// watch_dir starts fswatcher in a background goroutine and pipes events to a custom channel.
|
||||||
func watch_dir(ctx context.Context, path string, debounce time.Duration, eventChan chan<- fswatcher.WatchEvent) error {
|
func watch_dirs(ctx context.Context, paths []string, debounce time.Duration, eventChan chan<- fswatcher.WatchEvent) error {
|
||||||
w, err := fswatcher.New(
|
opts := []fswatcher.WatcherOpt{
|
||||||
fswatcher.WithPath(path),
|
|
||||||
fswatcher.WithCooldown(debounce),
|
fswatcher.WithCooldown(debounce),
|
||||||
)
|
}
|
||||||
|
for _, path := range paths {
|
||||||
|
opts = append(opts, fswatcher.WithPath(path))
|
||||||
|
}
|
||||||
|
w, err := fswatcher.New(opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -108,10 +111,9 @@ func watch_for_kitty_config_changes(action func() error, debounce_time time.Dura
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
for _, path := range dirs_to_watch {
|
|
||||||
if err := watch_dir(ctx, path, debounce_time, event_chan); err != nil {
|
if err := watch_dirs(ctx, dirs_to_watch, debounce_time, event_chan); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
|
||||||
}
|
}
|
||||||
stdinClosed := make(chan struct{})
|
stdinClosed := make(chan struct{})
|
||||||
go func() {
|
go func() {
|
||||||
|
|||||||
Reference in New Issue
Block a user