summaryrefslogtreecommitdiffstats
path: root/pkg/gui/commits_panel.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2018-09-12 18:23:25 +1000
committerJesse Duffield <jessedduffield@gmail.com>2018-09-12 18:23:25 +1000
commitf8b484f638e813537b9b968cf65d378b900fbcee (patch)
tree708fd1b05770b2020b2b16cff165688a9256bc81 /pkg/gui/commits_panel.go
parent52b132fe01156d8c7654180d03e40726e18692cd (diff)
don't use newlines at the end of panel buffers
Diffstat (limited to 'pkg/gui/commits_panel.go')
-rw-r--r--pkg/gui/commits_panel.go31
1 files changed, 19 insertions, 12 deletions
diff --git a/pkg/gui/commits_panel.go b/pkg/gui/commits_panel.go
index 1c1662475..dd33369a5 100644
--- a/pkg/gui/commits_panel.go
+++ b/pkg/gui/commits_panel.go
@@ -2,12 +2,27 @@ package gui
import (
"errors"
+ "fmt"
+ "strings"
"github.com/fatih/color"
"github.com/jesseduffield/gocui"
"github.com/jesseduffield/lazygit/pkg/commands"
)
+func (gui *Gui) renderCommit(commit commands.Commit) string {
+ red := color.New(color.FgRed)
+ yellow := color.New(color.FgYellow)
+ white := color.New(color.FgWhite)
+
+ shaColor := yellow
+ if commit.Pushed {
+ shaColor = red
+ }
+
+ return shaColor.Sprint(commit.Sha) + " " + white.Sprint(commit.Name)
+}
+
func (gui *Gui) refreshCommits(g *gocui.Gui) error {
g.Update(func(*gocui.Gui) error {
gui.State.Commits = gui.GitCommand.GetCommits()
@@ -16,19 +31,11 @@ func (gui *Gui) refreshCommits(g *gocui.Gui) error {
panic(err)
}
v.Clear()
- red := color.New(color.FgRed)
- yellow := color.New(color.FgYellow)
- white := color.New(color.FgWhite)
- shaColor := white
- for _, commit := range gui.State.Commits {
- if commit.Pushed {
- shaColor = red
- } else {
- shaColor = yellow
- }
- shaColor.Fprint(v, commit.Sha+" ")
- white.Fprintln(v, commit.Name)
+ displayStrings := make([]string, len(gui.State.Commits))
+ for i, commit := range gui.State.Commits {
+ displayStrings[i] = gui.renderCommit(commit)
}
+ fmt.Fprint(v, strings.Join(displayStrings, "\n"))
gui.refreshStatus(g)
if g.CurrentView().Name() == "commits" {
gui.handleCommitSelect(g, v)