mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-04-27 12:32:37 +02:00
don't use newlines at the end of panel buffers
This commit is contained in:
parent
52b132fe01
commit
f8b484f638
@ -152,9 +152,11 @@ func (gui *Gui) refreshBranches(g *gocui.Gui) error {
|
|||||||
}
|
}
|
||||||
gui.State.Branches = builder.Build()
|
gui.State.Branches = builder.Build()
|
||||||
v.Clear()
|
v.Clear()
|
||||||
|
displayStrings := []string{}
|
||||||
for _, branch := range gui.State.Branches {
|
for _, branch := range gui.State.Branches {
|
||||||
fmt.Fprintln(v, branch.GetDisplayString())
|
displayStrings = append(displayStrings, branch.GetDisplayString())
|
||||||
}
|
}
|
||||||
|
fmt.Fprint(v, strings.Join(displayStrings, "\n"))
|
||||||
gui.resetOrigin(v)
|
gui.resetOrigin(v)
|
||||||
return gui.refreshStatus(g)
|
return gui.refreshStatus(g)
|
||||||
})
|
})
|
||||||
|
@ -2,12 +2,27 @@ package gui
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/fatih/color"
|
"github.com/fatih/color"
|
||||||
"github.com/jesseduffield/gocui"
|
"github.com/jesseduffield/gocui"
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands"
|
"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 {
|
func (gui *Gui) refreshCommits(g *gocui.Gui) error {
|
||||||
g.Update(func(*gocui.Gui) error {
|
g.Update(func(*gocui.Gui) error {
|
||||||
gui.State.Commits = gui.GitCommand.GetCommits()
|
gui.State.Commits = gui.GitCommand.GetCommits()
|
||||||
@ -16,19 +31,11 @@ func (gui *Gui) refreshCommits(g *gocui.Gui) error {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
v.Clear()
|
v.Clear()
|
||||||
red := color.New(color.FgRed)
|
displayStrings := make([]string, len(gui.State.Commits))
|
||||||
yellow := color.New(color.FgYellow)
|
for i, commit := range gui.State.Commits {
|
||||||
white := color.New(color.FgWhite)
|
displayStrings[i] = gui.renderCommit(commit)
|
||||||
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)
|
|
||||||
}
|
}
|
||||||
|
fmt.Fprint(v, strings.Join(displayStrings, "\n"))
|
||||||
gui.refreshStatus(g)
|
gui.refreshStatus(g)
|
||||||
if g.CurrentView().Name() == "commits" {
|
if g.CurrentView().Name() == "commits" {
|
||||||
gui.handleCommitSelect(g, v)
|
gui.handleCommitSelect(g, v)
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
|
|
||||||
// "strings"
|
// "strings"
|
||||||
|
|
||||||
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/fatih/color"
|
"github.com/fatih/color"
|
||||||
@ -319,16 +320,15 @@ func (gui *Gui) refreshFiles(g *gocui.Gui) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
gui.refreshStateFiles()
|
gui.refreshStateFiles()
|
||||||
filesView.Clear()
|
|
||||||
|
displayStrings := make([]string, len(gui.State.Files))
|
||||||
for i, file := range gui.State.Files {
|
for i, file := range gui.State.Files {
|
||||||
str := gui.renderFile(file)
|
displayStrings[i] = gui.renderFile(file)
|
||||||
if i < len(gui.State.Files)-1 {
|
|
||||||
str += "\n"
|
|
||||||
}
|
|
||||||
if _, err := filesView.Write([]byte(str)); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
filesView.Clear()
|
||||||
|
fmt.Fprint(filesView, strings.Join(displayStrings, "\n"))
|
||||||
|
|
||||||
gui.correctCursor(filesView)
|
gui.correctCursor(filesView)
|
||||||
if filesView == g.CurrentView() {
|
if filesView == g.CurrentView() {
|
||||||
gui.handleFileSelect(g, filesView)
|
gui.handleFileSelect(g, filesView)
|
||||||
|
@ -2,6 +2,7 @@ package gui
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/jesseduffield/gocui"
|
"github.com/jesseduffield/gocui"
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands"
|
"github.com/jesseduffield/lazygit/pkg/commands"
|
||||||
@ -14,10 +15,15 @@ func (gui *Gui) refreshStashEntries(g *gocui.Gui) error {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
gui.State.StashEntries = gui.GitCommand.GetStashEntries()
|
gui.State.StashEntries = gui.GitCommand.GetStashEntries()
|
||||||
v.Clear()
|
|
||||||
for _, stashEntry := range gui.State.StashEntries {
|
displayStrings := make([]string, len(gui.State.StashEntries))
|
||||||
fmt.Fprintln(v, stashEntry.DisplayString)
|
for i, stashEntry := range gui.State.StashEntries {
|
||||||
|
displayStrings[i] = stashEntry.DisplayString
|
||||||
}
|
}
|
||||||
|
|
||||||
|
v.Clear()
|
||||||
|
fmt.Fprint(v, strings.Join(displayStrings, "\n"))
|
||||||
|
|
||||||
return gui.resetOrigin(v)
|
return gui.resetOrigin(v)
|
||||||
})
|
})
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
x
Reference in New Issue
Block a user