1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-13 01:30:53 +02:00

more consistent rendering

This commit is contained in:
Jesse Duffield
2021-11-03 08:23:47 +11:00
parent 06ca71e955
commit 9a9e3d506d
3 changed files with 54 additions and 53 deletions

View File

@ -23,6 +23,7 @@ import (
"github.com/jesseduffield/lazygit/pkg/gui/modes/diffing"
"github.com/jesseduffield/lazygit/pkg/gui/modes/filtering"
"github.com/jesseduffield/lazygit/pkg/gui/presentation/authors"
"github.com/jesseduffield/lazygit/pkg/gui/presentation/graph"
"github.com/jesseduffield/lazygit/pkg/gui/style"
"github.com/jesseduffield/lazygit/pkg/gui/types"
"github.com/jesseduffield/lazygit/pkg/i18n"
@ -462,8 +463,8 @@ func NewGui(log *logrus.Entry, gitCommand *commands.GitCommand, oSCommand *oscom
var RuneReplacements = map[rune]string{
// for the commit graph
'⏣': "M",
'⎔': "o",
graph.MergeSymbol: "M",
graph.CommitSymbol: "o",
}
// Run setup the gui with keybindings and start the mainloop

View File

@ -8,8 +8,8 @@ import (
"github.com/jesseduffield/lazygit/pkg/gui/style"
)
const mergeSymbol = "⏣"
const commitSymbol = "⎔"
const MergeSymbol = '⏣'
const CommitSymbol = '◯'
type cellType int
@ -35,9 +35,9 @@ func (cell *Cell) render(writer io.StringWriter) {
case CONNECTION:
adjustedFirst = first
case COMMIT:
adjustedFirst = commitSymbol
adjustedFirst = string(CommitSymbol)
case MERGE:
adjustedFirst = mergeSymbol
adjustedFirst = string(MergeSymbol)
}
var rightStyle *style.TextStyle

View File

@ -45,20 +45,20 @@ func TestRenderCommitGraph(t *testing.T) {
{Sha: "D", Parents: []string{"G"}},
},
expectedOutput: `
1
2
3
1
2
3
4 ⏣─╮
7 │
5 ─╯
8
7 │
5 ─╯
8
9 ⏣─╮
B │
D │
A
E
F
D ─╯`,
B │
D │
A
E
F
D ─╯`,
},
{
name: "with a path that has room to move to the left",
@ -71,12 +71,12 @@ func TestRenderCommitGraph(t *testing.T) {
{Sha: "6", Parents: []string{"7"}},
},
expectedOutput: `
1
1
2 ⏣─╮
4 │ ⏣─╮
3 ─╯ │
5 ───╯
6 `,
3 ─╯ │
5 ───╯
6 `,
},
{
name: "with a new commit",
@ -90,13 +90,13 @@ func TestRenderCommitGraph(t *testing.T) {
{Sha: "6", Parents: []string{"7"}},
},
expectedOutput: `
1
1
2 ⏣─╮
4 │ ⏣─╮
Z │ │ │
3 ─╯ │ │
5 ───╯ │
6 ╭───╯`,
Z │ │ │
3 ─╯ │ │
5 ───╯ │
6 ╭───╯`,
},
{
name: "with a path that has room to move to the left and continues",
@ -109,12 +109,12 @@ func TestRenderCommitGraph(t *testing.T) {
{Sha: "7", Parents: []string{"11"}},
},
expectedOutput: `
1
1
2 ⏣─╮
3 ⏣─│─╮
5 ⏣─│─│─╮
4 │ ─╯ │
7 ─╯ ╭─╯`,
4 │ ─╯ │
7 ─╯ ╭─╯`,
},
{
name: "with a path that has room to move to the left and continues",
@ -128,13 +128,13 @@ func TestRenderCommitGraph(t *testing.T) {
{Sha: "B", Parents: []string{"C"}},
},
expectedOutput: `
1
1
2 ⏣─╮
3 ⏣─│─╮
5 ⏣─│─│─╮
7 ⏣─│─│─│─╮
4 ─┴─╯ │ │
B ╭───╯ │`,
4 ─┴─╯ │ │
B ╭───╯ │`,
},
{
name: "with a path that has room to move to the left and continues",
@ -147,10 +147,10 @@ func TestRenderCommitGraph(t *testing.T) {
},
expectedOutput: `
1 ⏣─╮
3 │
3 │
2 ⏣─│
4 ⏣─│─╮
6 │ │`,
6 │ │`,
},
{
name: "new merge path fills gap before continuing path on right",
@ -163,10 +163,10 @@ func TestRenderCommitGraph(t *testing.T) {
},
expectedOutput: `
1 ⏣─┬─┬─╮
4 │ │
2 ─│─╯ │
4 │ │
2 ─│─╯ │
A ⏣─│─╮ │
B │ │ `,
B │ │ `,
},
{
name: "with a path that has room to move to the left and continues",
@ -181,14 +181,14 @@ func TestRenderCommitGraph(t *testing.T) {
{Sha: "C", Parents: []string{"D"}},
},
expectedOutput: `
1
1
2 ⏣─╮
3 ⏣─│─╮
5 ⏣─│─│─╮
7 ⏣─│─│─│─╮
4 ─┴─╯ │ │
B ╭───╯ │
C │ ╭───╯`,
4 ─┴─╯ │ │
B ╭───╯ │
C │ ╭───╯`,
},
{
name: "with a path that has room to move to the left and continues",
@ -205,16 +205,16 @@ func TestRenderCommitGraph(t *testing.T) {
{Sha: "D", Parents: []string{"F"}},
},
expectedOutput: `
1
1
2 ⏣─╮
3 ⏣─│─╮
5 ⏣─│─│─╮
7 ⏣─│─│─│─╮
8 ⏣─│─│─│─│─╮
4 ─┴─╯ │ │ │
B ╭───╯ │ │
C │ ╭───╯ │
D │ │ ╭───╯`,
4 ─┴─╯ │ │ │
B ╭───╯ │ │
C │ ╭───╯ │
D │ │ ╭───╯`,
},
}
@ -269,7 +269,7 @@ func TestRenderPipeSet(t *testing.T) {
{fromPos: 0, toPos: 0, fromSha: "b", toSha: "c", kind: STARTS, style: green},
},
prevCommit: &models.Commit{Sha: "a"},
expectedStr: "",
expectedStr: "",
expectedStyles: []style.TextStyle{green},
},
{
@ -279,7 +279,7 @@ func TestRenderPipeSet(t *testing.T) {
{fromPos: 0, toPos: 0, fromSha: "selected", toSha: "c", kind: STARTS, style: green},
},
prevCommit: &models.Commit{Sha: "a"},
expectedStr: "",
expectedStr: "",
expectedStyles: []style.TextStyle{highlightStyle},
},
{
@ -349,7 +349,7 @@ func TestRenderPipeSet(t *testing.T) {
{fromPos: 2, toPos: 0, fromSha: "c1", toSha: "a2", kind: TERMINATES, style: green},
},
prevCommit: &models.Commit{Sha: "a1"},
expectedStr: "─┴─╯",
expectedStr: "─┴─╯",
expectedStyles: []style.TextStyle{
yellow, magenta, magenta, green, green,
},
@ -406,7 +406,7 @@ func TestRenderPipeSet(t *testing.T) {
{fromPos: 0, toPos: 0, fromSha: "a2", toSha: "a3", kind: STARTS, style: yellow},
},
prevCommit: &models.Commit{Sha: "selected"},
expectedStr: "",
expectedStr: "",
expectedStyles: []style.TextStyle{
yellow,
},
@ -418,7 +418,7 @@ func TestRenderPipeSet(t *testing.T) {
{fromPos: 1, toPos: 1, fromSha: "selected", toSha: "b3", kind: CONTINUES, style: red},
},
prevCommit: &models.Commit{Sha: "selected"},
expectedStr: " │",
expectedStr: " │",
expectedStyles: []style.TextStyle{
highlightStyle, nothing, highlightStyle,
},
@ -431,7 +431,7 @@ func TestRenderPipeSet(t *testing.T) {
{fromPos: 2, toPos: 2, fromSha: "selected", toSha: "b3", kind: CONTINUES, style: red},
},
prevCommit: &models.Commit{Sha: "selected"},
expectedStr: " │ │",
expectedStr: " │ │",
expectedStyles: []style.TextStyle{
highlightStyle, nothing, green, nothing, highlightStyle,
},