1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-30 03:23:08 +03:00

add file watching for modified files

log createErrorPanel error

swallow error when adding file to watcher
This commit is contained in:
Jesse Duffield
2019-11-12 22:19:20 +11:00
parent 7995d56a85
commit f15e47bb67
3 changed files with 101 additions and 17 deletions

View File

@ -14,6 +14,7 @@ import (
"strings"
"time"
"github.com/fsnotify/fsnotify"
"github.com/go-errors/errors"
// "strings"
@ -79,6 +80,7 @@ type Gui struct {
statusManager *statusManager
credentials credentials
waitForIntro sync.WaitGroup
fileWatcher *fsnotify.Watcher
}
// for now the staging panel state, unlike the other panel states, is going to be
@ -145,22 +147,24 @@ type panelStates struct {
}
type guiState struct {
Files []*commands.File
Branches []*commands.Branch
Commits []*commands.Commit
StashEntries []*commands.StashEntry
CommitFiles []*commands.CommitFile
DiffEntries []*commands.Commit
MenuItemCount int // can't store the actual list because it's of interface{} type
PreviousView string
Platform commands.Platform
Updating bool
Panels *panelStates
WorkingTreeState string // one of "merging", "rebasing", "normal"
Context string // important not to set this value directly but to use gui.changeContext("new context")
CherryPickedCommits []*commands.Commit
SplitMainPanel bool
RetainOriginalDir bool
Files []*commands.File
Branches []*commands.Branch
Commits []*commands.Commit
StashEntries []*commands.StashEntry
CommitFiles []*commands.CommitFile
DiffEntries []*commands.Commit
MenuItemCount int // can't store the actual list because it's of interface{} type
PreviousView string
Platform commands.Platform
Updating bool
Panels *panelStates
WorkingTreeState string // one of "merging", "rebasing", "normal"
Context string // important not to set this value directly but to use gui.changeContext("new context")
CherryPickedCommits []*commands.Commit
SplitMainPanel bool
RetainOriginalDir bool
IsRefreshingFiles bool
RefreshingFilesMutex sync.Mutex
}
// for now the split view will always be on
@ -204,6 +208,8 @@ func NewGui(log *logrus.Entry, gitCommand *commands.GitCommand, oSCommand *comma
statusManager: &statusManager{},
}
gui.watchFilesForChanges()
gui.GenerateSentinelErrors()
return gui, nil
@ -786,6 +792,8 @@ func (gui *Gui) RunWithSubprocesses() error {
}
}
gui.fileWatcher.Close()
break
} else if err == gui.Errors.ErrSwitchRepo {
continue