diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2020-03-29 13:56:03 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2020-03-29 18:26:24 +1100 |
commit | 33d287d2f0c6335559ac75c1b9a4705dfaa9ad7b (patch) | |
tree | 3e687983a7013ce2f02e471315755b6b54f4e956 /pkg/gui | |
parent | 9eb1cbc51434697e4a7edac8bd14839847719af3 (diff) |
remove old diff mode code
Diffstat (limited to 'pkg/gui')
-rw-r--r-- | pkg/gui/commits_panel.go | 50 | ||||
-rw-r--r-- | pkg/gui/gui.go | 9 | ||||
-rw-r--r-- | pkg/gui/keybindings.go | 8 | ||||
-rw-r--r-- | pkg/gui/presentation/commits.go | 34 |
4 files changed, 26 insertions, 75 deletions
diff --git a/pkg/gui/commits_panel.go b/pkg/gui/commits_panel.go index 80fcf23c8..d2bfd4b63 100644 --- a/pkg/gui/commits_panel.go +++ b/pkg/gui/commits_panel.go @@ -117,7 +117,7 @@ func (gui *Gui) refreshCommits() error { } func (gui *Gui) refreshCommitsWithLimit() error { - builder, err := commands.NewCommitListBuilder(gui.Log, gui.GitCommand, gui.OSCommand, gui.Tr, gui.State.CherryPickedCommits, gui.State.DiffEntries) + builder, err := commands.NewCommitListBuilder(gui.Log, gui.GitCommand, gui.OSCommand, gui.Tr, gui.State.CherryPickedCommits) if err != nil { return err } @@ -491,52 +491,6 @@ func (gui *Gui) handleSwitchToCommitFilesPanel(g *gocui.Gui, v *gocui.View) erro return gui.switchFocus(g, gui.getCommitsView(), gui.getCommitFilesView()) } -func (gui *Gui) handleToggleDiffCommit(g *gocui.Gui, v *gocui.View) error { - selectLimit := 2 - - // get selected commit - commit := gui.getSelectedCommit(g) - if commit == nil { - return gui.newStringTask("main", gui.Tr.SLocalize("NoCommitsThisBranch")) - } - - // if already selected commit delete - if idx, has := gui.hasCommit(gui.State.DiffEntries, commit.Sha); has { - gui.State.DiffEntries = gui.unchooseCommit(gui.State.DiffEntries, idx) - } else { - if len(gui.State.DiffEntries) == 0 { - gui.State.DiffEntries = []*commands.Commit{commit} - } else { - gui.State.DiffEntries = append(gui.State.DiffEntries[:1], commit) - } - } - - gui.setDiffMode() - - // if selected two commits, display diff between - if len(gui.State.DiffEntries) == selectLimit { - commitText, err := gui.GitCommand.DiffCommits(gui.State.DiffEntries[0].Sha, gui.State.DiffEntries[1].Sha) - - if err != nil { - return gui.surfaceError(err) - } - - gui.newStringTask("main", commitText) - } - return gui.renderBranchCommitsWithSelection() -} - -func (gui *Gui) setDiffMode() { - v := gui.getCommitsView() - if len(gui.State.DiffEntries) != 0 { - gui.State.Panels.Commits.SpecificDiffMode = true - v.Title = gui.Tr.SLocalize("CommitsDiffTitle") - } else { - gui.State.Panels.Commits.SpecificDiffMode = false - v.Title = gui.Tr.SLocalize("CommitsTitle") - } -} - func (gui *Gui) hasCommit(commits []*commands.Commit, target string) (int, bool) { for idx, commit := range commits { if commit.Sha == target { @@ -633,7 +587,7 @@ func (gui *Gui) renderBranchCommitsWithSelection() error { commitsView := gui.getCommitsView() gui.refreshSelectedLine(&gui.State.Panels.Commits.SelectedLine, len(gui.State.Commits)) - displayStrings := presentation.GetCommitListDisplayStrings(gui.State.Commits, gui.State.ScreenMode != SCREEN_NORMAL, gui.cherryPickedCommitShaMap(), gui.State.DiffEntries) + displayStrings := presentation.GetCommitListDisplayStrings(gui.State.Commits, gui.State.ScreenMode != SCREEN_NORMAL, gui.cherryPickedCommitShaMap()) gui.renderDisplayStrings(commitsView, displayStrings) if gui.g.CurrentView() == commitsView && commitsView.Context == "branch-commits" { if err := gui.handleCommitSelect(gui.g, commitsView); err != nil { diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index 17ba0c00b..62e18f8fd 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -185,6 +185,12 @@ const ( COMPLETE ) +// if ref is blank we're not diffing anything +type DiffState struct { + Ref string + Left bool +} + type guiState struct { Files []*commands.File Branches []*commands.Branch @@ -198,7 +204,6 @@ type guiState struct { // if we're not in filtering mode, CommitFiles and FilteredReflogCommits will be // one and the same ReflogCommits []*commands.Commit - DiffEntries []*commands.Commit Remotes []*commands.Remote RemoteBranches []*commands.RemoteBranch Tags []*commands.Tag @@ -222,6 +227,7 @@ type guiState struct { OldInformation string StartupStage int // one of INITIAL and COMPLETE. Allows us to not load everything at once FilterPath string // the filename that gets passed to git log + Diff DiffState } func (gui *Gui) resetState() { @@ -239,7 +245,6 @@ func (gui *Gui) resetState() { ReflogCommits: make([]*commands.Commit, 0), CherryPickedCommits: make([]*commands.Commit, 0), StashEntries: make([]*commands.StashEntry, 0), - DiffEntries: make([]*commands.Commit, 0), Panels: &panelStates{ Files: &filePanelState{SelectedLine: -1}, Branches: &branchPanelState{SelectedLine: 0}, diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go index 1061d99b1..486ea9a31 100644 --- a/pkg/gui/keybindings.go +++ b/pkg/gui/keybindings.go @@ -838,14 +838,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "commits", Contexts: []string{"branch-commits"}, - Key: gui.getKey("commits.toggleDiffCommit"), - Modifier: gocui.ModNone, - Handler: gui.handleToggleDiffCommit, - Description: gui.Tr.SLocalize("CommitsDiff"), - }, - { - ViewName: "commits", - Contexts: []string{"branch-commits"}, Key: gui.getKey("commits.tagCommit"), Modifier: gocui.ModNone, Handler: gui.handleTagCommit, diff --git a/pkg/gui/presentation/commits.go b/pkg/gui/presentation/commits.go index d2aff9817..5463cd531 100644 --- a/pkg/gui/presentation/commits.go +++ b/pkg/gui/presentation/commits.go @@ -9,10 +9,10 @@ import ( "github.com/jesseduffield/lazygit/pkg/utils" ) -func GetCommitListDisplayStrings(commits []*commands.Commit, fullDescription bool, cherryPickedCommitShaMap map[string]bool, diffEntries []*commands.Commit) [][]string { +func GetCommitListDisplayStrings(commits []*commands.Commit, fullDescription bool, cherryPickedCommitShaMap map[string]bool) [][]string { lines := make([][]string, len(commits)) - var displayFunc func(*commands.Commit, map[string]bool, []*commands.Commit) []string + var displayFunc func(*commands.Commit, map[string]bool) []string if fullDescription { displayFunc = getFullDescriptionDisplayStringsForCommit } else { @@ -20,20 +20,20 @@ func GetCommitListDisplayStrings(commits []*commands.Commit, fullDescription boo } for i := range commits { - lines[i] = displayFunc(commits[i], cherryPickedCommitShaMap, diffEntries) + lines[i] = displayFunc(commits[i], cherryPickedCommitShaMap) } return lines } -func getFullDescriptionDisplayStringsForCommit(c *commands.Commit, cherryPickedCommitShaMap map[string]bool, diffEntries []*commands.Commit) []string { +func getFullDescriptionDisplayStringsForCommit(c *commands.Commit, cherryPickedCommitShaMap map[string]bool) []string { red := color.New(color.FgRed) yellow := color.New(color.FgYellow) green := color.New(color.FgGreen) blue := color.New(color.FgBlue) cyan := color.New(color.FgCyan) defaultColor := color.New(theme.DefaultTextColor) - magenta := color.New(color.FgMagenta) + // magenta := color.New(color.FgMagenta) // for some reason, setting the background to blue pads out the other commits // horizontally. For the sake of accessibility I'm considering this a feature, @@ -60,11 +60,11 @@ func getFullDescriptionDisplayStringsForCommit(c *commands.Commit, cherryPickedC shaColor = copied } - for _, entry := range diffEntries { - if c.Sha == entry.Sha { - shaColor = magenta - } - } + // for _, entry := range diffEntries { + // if c.Sha == entry.Sha { + // shaColor = magenta + // } + // } tagString := "" secondColumnString := blue.Sprint(utils.UnixToDate(c.UnixTimestamp)) @@ -80,14 +80,14 @@ func getFullDescriptionDisplayStringsForCommit(c *commands.Commit, cherryPickedC return []string{shaColor.Sprint(c.ShortSha()), secondColumnString, yellow.Sprint(truncatedAuthor), tagString + defaultColor.Sprint(c.Name)} } -func getDisplayStringsForCommit(c *commands.Commit, cherryPickedCommitShaMap map[string]bool, diffEntries []*commands.Commit) []string { +func getDisplayStringsForCommit(c *commands.Commit, cherryPickedCommitShaMap map[string]bool) []string { red := color.New(color.FgRed) yellow := color.New(color.FgYellow) green := color.New(color.FgGreen) blue := color.New(color.FgBlue) cyan := color.New(color.FgCyan) defaultColor := color.New(theme.DefaultTextColor) - magenta := color.New(color.FgMagenta) + // magenta := color.New(color.FgMagenta) // for some reason, setting the background to blue pads out the other commits // horizontally. For the sake of accessibility I'm considering this a feature, @@ -114,11 +114,11 @@ func getDisplayStringsForCommit(c *commands.Commit, cherryPickedCommitShaMap map shaColor = copied } - for _, entry := range diffEntries { - if c.Sha == entry.Sha { - shaColor = magenta - } - } + // for _, entry := range diffEntries { + // if c.Sha == entry.Sha { + // shaColor = magenta + // } + // } actionString := "" tagString := "" |