mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-03-23 21:51:07 +02:00
minor fixup
This commit is contained in:
parent
ba4253668d
commit
c7d367a791
@ -4,7 +4,6 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/davecgh/go-spew/spew"
|
|
||||||
"github.com/fsnotify/fsnotify"
|
"github.com/fsnotify/fsnotify"
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands"
|
"github.com/jesseduffield/lazygit/pkg/commands"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
@ -67,13 +66,17 @@ func (w *fileWatcher) watchFilename(filename string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *fileWatcher) addFilesToFileWatcher(files []*commands.File) error {
|
func (w *fileWatcher) addFilesToFileWatcher(files []*commands.File) error {
|
||||||
|
if len(files) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// watch the files for changes
|
// watch the files for changes
|
||||||
dirName, err := os.Getwd()
|
dirName, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, file := range files {
|
for _, file := range files[0:min(MAX_WATCHED_FILES, len(files))] {
|
||||||
filename := filepath.Join(dirName, file.Name)
|
filename := filepath.Join(dirName, file.Name)
|
||||||
if w.watchingFilename(filename) {
|
if w.watchingFilename(filename) {
|
||||||
continue
|
continue
|
||||||
@ -83,12 +86,18 @@ func (w *fileWatcher) addFilesToFileWatcher(files []*commands.File) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
w.watchFilename(filename)
|
w.watchFilename(filename)
|
||||||
w.Log.Warn(spew.Sdump(w.WatchedFilenames))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func min(a int, b int) int {
|
||||||
|
if a < b {
|
||||||
|
return a
|
||||||
|
}
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
// NOTE: given that we often edit files ourselves, this may make us end up refreshing files too often
|
// NOTE: given that we often edit files ourselves, this may make us end up refreshing files too often
|
||||||
// TODO: consider watching the whole directory recursively (could be more expensive)
|
// TODO: consider watching the whole directory recursively (could be more expensive)
|
||||||
func (gui *Gui) watchFilesForChanges() {
|
func (gui *Gui) watchFilesForChanges() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user