diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2019-03-11 13:04:08 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2019-03-16 10:20:27 +1100 |
commit | 4f7f6a073ced1b31be6bbac119d1f0f4de229578 (patch) | |
tree | 492d67c4e51b4593c74d26e9a46c434f11c267f7 /pkg/gui/commits_panel.go | |
parent | 0e008cc15f8e7cbb6869151d48ae30403bf4dc70 (diff) |
allow user to discard old file changes for a given commit
Diffstat (limited to 'pkg/gui/commits_panel.go')
-rw-r--r-- | pkg/gui/commits_panel.go | 37 |
1 files changed, 6 insertions, 31 deletions
diff --git a/pkg/gui/commits_panel.go b/pkg/gui/commits_panel.go index 0de71e875..9b83d725d 100644 --- a/pkg/gui/commits_panel.go +++ b/pkg/gui/commits_panel.go @@ -3,7 +3,6 @@ package gui import ( "fmt" "strconv" - "strings" "github.com/go-errors/errors" @@ -72,9 +71,12 @@ func (gui *Gui) refreshCommits(g *gocui.Gui) error { fmt.Fprint(v, list) gui.refreshStatus(g) - if v == g.CurrentView() { + if g.CurrentView() == v { gui.handleCommitSelect(g, v) } + if g.CurrentView() == gui.getCommitFilesView() { + gui.refreshCommitFilesView() + } return nil }) return nil @@ -440,36 +442,9 @@ func (gui *Gui) HandlePasteCommits(g *gocui.Gui, v *gocui.View) error { } func (gui *Gui) handleSwitchToCommitFilesPanel(g *gocui.Gui, v *gocui.View) error { - commit := gui.getSelectedCommit(g) - if commit == nil { - return nil - } - - commitfileView, err := g.View("commitFiles") - if err != nil { + if err := gui.refreshCommitFilesView(); err != nil { return err } - files, err := gui.GitCommand.CommitFiles(commit.Sha) - if err != nil { - return gui.createErrorPanel(g, err.Error()) - } - - gui.State.Panels.CommitFiles = &commitFilesPanelState{SelectedLine: 0} - gui.State.CommitFiles = make([]*commands.CommitFile, 0) - - if files == "" { - gui.State.Panels.CommitFiles.SelectedLine = -1 - } - - for _, file := range strings.Split(strings.TrimRight(files, "\n"), "\n") { - gui.State.CommitFiles = append(gui.State.CommitFiles, &commands.CommitFile{ - Sha: commit.Sha, - Name: file, - DisplayString: file, - }) - } - - gui.renderListPanel(gui.getCommitFilesView(), gui.State.CommitFiles) - return gui.switchFocus(g, v, commitfileView) + return gui.switchFocus(g, v, gui.getCommitFilesView()) } |