mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-11-29 22:48:24 +02:00
smart refreshing files
This commit is contained in:
@@ -67,7 +67,7 @@ func (gui *Gui) handleCheckoutCommitFile(g *gocui.Gui, v *gocui.View) error {
|
|||||||
return gui.createErrorPanel(gui.g, err.Error())
|
return gui.createErrorPanel(gui.g, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
return gui.refreshFiles()
|
return gui.refreshSidePanels(refreshOptions{mode: ASYNC})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) handleDiscardOldFileChange(g *gocui.Gui, v *gocui.View) error {
|
func (gui *Gui) handleDiscardOldFileChange(g *gocui.Gui, v *gocui.View) error {
|
||||||
|
|||||||
@@ -36,19 +36,9 @@ func (gui *Gui) waitForPassUname(g *gocui.Gui, currentView *gocui.View, passOrUn
|
|||||||
func (gui *Gui) handleSubmitCredential(g *gocui.Gui, v *gocui.View) error {
|
func (gui *Gui) handleSubmitCredential(g *gocui.Gui, v *gocui.View) error {
|
||||||
message := gui.trimmedContent(v)
|
message := gui.trimmedContent(v)
|
||||||
gui.credentials <- message
|
gui.credentials <- message
|
||||||
err := gui.refreshFiles()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
v.Clear()
|
v.Clear()
|
||||||
err = v.SetCursor(0, 0)
|
_ = v.SetCursor(0, 0)
|
||||||
if err != nil {
|
_, _ = g.SetViewOnBottom("credentials")
|
||||||
return err
|
|
||||||
}
|
|
||||||
_, err = g.SetViewOnBottom("credentials")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
nextView, err := gui.g.View("confirmation")
|
nextView, err := gui.g.View("confirmation")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
nextView = gui.getFilesView()
|
nextView = gui.getFilesView()
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ func (gui *Gui) handleCreateDiscardMenu(g *gocui.Gui, v *gocui.View) error {
|
|||||||
if err := gui.GitCommand.DiscardAllFileChanges(file); err != nil {
|
if err := gui.GitCommand.DiscardAllFileChanges(file); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return gui.refreshFiles()
|
return gui.refreshSidePanels(refreshOptions{mode: ASYNC, scope: []int{FILES}})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -33,7 +33,7 @@ func (gui *Gui) handleCreateDiscardMenu(g *gocui.Gui, v *gocui.View) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return gui.refreshFiles()
|
return gui.refreshSidePanels(refreshOptions{mode: ASYNC, scope: []int{FILES}})
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -132,12 +132,7 @@ func (gui *Gui) watchFilesForChanges() {
|
|||||||
}
|
}
|
||||||
// only refresh if we're not already
|
// only refresh if we're not already
|
||||||
if !gui.State.IsRefreshingFiles {
|
if !gui.State.IsRefreshingFiles {
|
||||||
if err := gui.refreshFiles(); err != nil {
|
gui.refreshSidePanels(refreshOptions{mode: ASYNC, scope: []int{FILES}})
|
||||||
err = gui.createErrorPanel(gui.g, err.Error())
|
|
||||||
if err != nil {
|
|
||||||
gui.Log.Error(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// watch for errors
|
// watch for errors
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ func (gui *Gui) handleFilePress(g *gocui.Gui, v *gocui.View) error {
|
|||||||
return gui.createErrorPanel(gui.g, err.Error())
|
return gui.createErrorPanel(gui.g, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := gui.refreshFiles(); err != nil {
|
if err := gui.refreshSidePanels(refreshOptions{scope: []int{FILES}}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,7 +229,7 @@ func (gui *Gui) handleStageAll(g *gocui.Gui, v *gocui.View) error {
|
|||||||
_ = gui.createErrorPanel(g, err.Error())
|
_ = gui.createErrorPanel(g, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := gui.refreshFiles(); err != nil {
|
if err := gui.refreshSidePanels(refreshOptions{scope: []int{FILES}}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,7 +252,7 @@ func (gui *Gui) handleIgnoreFile(g *gocui.Gui, v *gocui.View) error {
|
|||||||
if err := gui.GitCommand.RemoveTrackedFiles(file.Name); err != nil {
|
if err := gui.GitCommand.RemoveTrackedFiles(file.Name); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return gui.refreshFiles()
|
return gui.refreshSidePanels(refreshOptions{scope: []int{FILES}})
|
||||||
}, nil)
|
}, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -260,7 +260,7 @@ func (gui *Gui) handleIgnoreFile(g *gocui.Gui, v *gocui.View) error {
|
|||||||
return gui.createErrorPanel(gui.g, err.Error())
|
return gui.createErrorPanel(gui.g, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
return gui.refreshFiles()
|
return gui.refreshSidePanels(refreshOptions{scope: []int{FILES}})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) handleWIPCommitPress(g *gocui.Gui, filesView *gocui.View) error {
|
func (gui *Gui) handleWIPCommitPress(g *gocui.Gui, filesView *gocui.View) error {
|
||||||
@@ -362,7 +362,7 @@ func (gui *Gui) handleFileOpen(g *gocui.Gui, v *gocui.View) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) handleRefreshFiles(g *gocui.Gui, v *gocui.View) error {
|
func (gui *Gui) handleRefreshFiles(g *gocui.Gui, v *gocui.View) error {
|
||||||
return gui.refreshFiles()
|
return gui.refreshSidePanels(refreshOptions{scope: []int{FILES}})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) refreshStateFiles() error {
|
func (gui *Gui) refreshStateFiles() error {
|
||||||
|
|||||||
@@ -261,7 +261,7 @@ func (gui *Gui) renderMergeOptions() error {
|
|||||||
|
|
||||||
func (gui *Gui) handleEscapeMerge(g *gocui.Gui, v *gocui.View) error {
|
func (gui *Gui) handleEscapeMerge(g *gocui.Gui, v *gocui.View) error {
|
||||||
gui.State.Panels.Merging.EditHistory = stack.New()
|
gui.State.Panels.Merging.EditHistory = stack.New()
|
||||||
if err := gui.refreshFiles(); err != nil {
|
if err := gui.refreshSidePanels(refreshOptions{scope: []int{FILES}}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// it's possible this method won't be called from the merging view so we need to
|
// it's possible this method won't be called from the merging view so we need to
|
||||||
@@ -276,7 +276,7 @@ func (gui *Gui) handleCompleteMerge() error {
|
|||||||
if err := gui.stageSelectedFile(gui.g); err != nil {
|
if err := gui.stageSelectedFile(gui.g); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := gui.refreshFiles(); err != nil {
|
if err := gui.refreshSidePanels(refreshOptions{scope: []int{FILES}}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// if we got conflicts after unstashing, we don't want to call any git
|
// if we got conflicts after unstashing, we don't want to call any git
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ func (gui *Gui) applySelection(reverse bool) error {
|
|||||||
state.SelectMode = LINE
|
state.SelectMode = LINE
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := gui.refreshFiles(); err != nil {
|
if err := gui.refreshSidePanels(refreshOptions{scope: []int{FILES}}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := gui.refreshStagingPanel(false, -1); err != nil {
|
if err := gui.refreshStagingPanel(false, -1); err != nil {
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ const (
|
|||||||
REFLOG
|
REFLOG
|
||||||
TAGS
|
TAGS
|
||||||
REMOTES
|
REMOTES
|
||||||
|
STATUS
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -55,7 +56,7 @@ func (gui *Gui) refreshSidePanels(options refreshOptions) error {
|
|||||||
f := func() {
|
f := func() {
|
||||||
var scopeMap map[int]bool
|
var scopeMap map[int]bool
|
||||||
if len(options.scope) == 0 {
|
if len(options.scope) == 0 {
|
||||||
scopeMap = intArrToMap([]int{COMMITS, BRANCHES, FILES, STASH, REFLOG, TAGS, REMOTES})
|
scopeMap = intArrToMap([]int{COMMITS, BRANCHES, FILES, STASH, REFLOG, TAGS, REMOTES, STATUS})
|
||||||
} else {
|
} else {
|
||||||
scopeMap = intArrToMap(options.scope)
|
scopeMap = intArrToMap(options.scope)
|
||||||
}
|
}
|
||||||
@@ -82,7 +83,6 @@ func (gui *Gui) refreshSidePanels(options refreshOptions) error {
|
|||||||
}
|
}
|
||||||
wg.Done()
|
wg.Done()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if scopeMap[STASH] {
|
if scopeMap[STASH] {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ func (gui *Gui) handleCreateResetMenu(g *gocui.Gui, v *gocui.View) error {
|
|||||||
return gui.createErrorPanel(gui.g, err.Error())
|
return gui.createErrorPanel(gui.g, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
return gui.refreshFiles()
|
return gui.refreshSidePanels(refreshOptions{mode: ASYNC, scope: []int{FILES}})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -32,7 +32,7 @@ func (gui *Gui) handleCreateResetMenu(g *gocui.Gui, v *gocui.View) error {
|
|||||||
return gui.createErrorPanel(gui.g, err.Error())
|
return gui.createErrorPanel(gui.g, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
return gui.refreshFiles()
|
return gui.refreshSidePanels(refreshOptions{mode: ASYNC, scope: []int{FILES}})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -45,7 +45,7 @@ func (gui *Gui) handleCreateResetMenu(g *gocui.Gui, v *gocui.View) error {
|
|||||||
return gui.createErrorPanel(gui.g, err.Error())
|
return gui.createErrorPanel(gui.g, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
return gui.refreshFiles()
|
return gui.refreshSidePanels(refreshOptions{mode: ASYNC, scope: []int{FILES}})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -58,7 +58,7 @@ func (gui *Gui) handleCreateResetMenu(g *gocui.Gui, v *gocui.View) error {
|
|||||||
return gui.createErrorPanel(gui.g, err.Error())
|
return gui.createErrorPanel(gui.g, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
return gui.refreshFiles()
|
return gui.refreshSidePanels(refreshOptions{mode: ASYNC, scope: []int{FILES}})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -71,7 +71,7 @@ func (gui *Gui) handleCreateResetMenu(g *gocui.Gui, v *gocui.View) error {
|
|||||||
return gui.createErrorPanel(gui.g, err.Error())
|
return gui.createErrorPanel(gui.g, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
return gui.refreshFiles()
|
return gui.refreshSidePanels(refreshOptions{mode: ASYNC, scope: []int{FILES}})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -84,7 +84,7 @@ func (gui *Gui) handleCreateResetMenu(g *gocui.Gui, v *gocui.View) error {
|
|||||||
return gui.createErrorPanel(gui.g, err.Error())
|
return gui.createErrorPanel(gui.g, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
return gui.refreshFiles()
|
return gui.refreshSidePanels(refreshOptions{mode: ASYNC, scope: []int{FILES}})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user