Use timer instead of ticker

This commit is contained in:
Joe Lim committed 2024-04-05 17:12:24 +11:00
1 parent 33f7204c49
commit be9113e64a
2 files changed
+8 -6

No files matched your search

+6 -2
View File
@@ -477,9 +477,13 @@ func (app *app) loop() {
}
if ev.Has(fsnotify.Write) || ev.Has(fsnotify.Chmod) {
app.nav.watcherWrites[ev.Name] = true
if !app.nav.watcherWrites[ev.Name] {
app.nav.watcherWrites[ev.Name] = true
app.nav.watcherTimer.Stop()
app.nav.watcherTimer.Reset(10 * time.Millisecond)
}
}
case <-app.nav.watcherTicker.C:
case <-app.nav.watcherTimer.C:
for path := range app.nav.watcherWrites {
app.updateFile(path, true)
currFile, err := app.nav.currFile()