Skip to content

Commit 9a9e3d5

Browse files
committed
more consistent rendering
1 parent 06ca71e commit 9a9e3d5

File tree

3 files changed

+54
-53
lines changed

3 files changed

+54
-53
lines changed

pkg/gui/gui.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"github.com/jesseduffield/lazygit/pkg/gui/modes/diffing"
2424
"github.com/jesseduffield/lazygit/pkg/gui/modes/filtering"
2525
"github.com/jesseduffield/lazygit/pkg/gui/presentation/authors"
26+
"github.com/jesseduffield/lazygit/pkg/gui/presentation/graph"
2627
"github.com/jesseduffield/lazygit/pkg/gui/style"
2728
"github.com/jesseduffield/lazygit/pkg/gui/types"
2829
"github.com/jesseduffield/lazygit/pkg/i18n"
@@ -462,8 +463,8 @@ func NewGui(log *logrus.Entry, gitCommand *commands.GitCommand, oSCommand *oscom
462463

463464
var RuneReplacements = map[rune]string{
464465
// for the commit graph
465-
'⏣': "M",
466-
'⎔': "o",
466+
graph.MergeSymbol: "M",
467+
graph.CommitSymbol: "o",
467468
}
468469

469470
// Run setup the gui with keybindings and start the mainloop

pkg/gui/presentation/graph/cell.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import (
88
"github.com/jesseduffield/lazygit/pkg/gui/style"
99
)
1010

11-
const mergeSymbol = "⏣"
12-
const commitSymbol = "⎔"
11+
const MergeSymbol = '⏣'
12+
const CommitSymbol = '◯'
1313

1414
type cellType int
1515

@@ -35,9 +35,9 @@ func (cell *Cell) render(writer io.StringWriter) {
3535
case CONNECTION:
3636
adjustedFirst = first
3737
case COMMIT:
38-
adjustedFirst = commitSymbol
38+
adjustedFirst = string(CommitSymbol)
3939
case MERGE:
40-
adjustedFirst = mergeSymbol
40+
adjustedFirst = string(MergeSymbol)
4141
}
4242

4343
var rightStyle *style.TextStyle

pkg/gui/presentation/graph/graph_test.go

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,20 @@ func TestRenderCommitGraph(t *testing.T) {
4545
{Sha: "D", Parents: []string{"G"}},
4646
},
4747
expectedOutput: `
48-
1
49-
2
50-
3
48+
1
49+
2
50+
3
5151
4 ⏣─╮
52-
7 │
53-
5 ─╯
54-
8
52+
7 │
53+
5 ─╯
54+
8
5555
9 ⏣─╮
56-
B │
57-
D │
58-
A
59-
E
60-
F
61-
D ─╯`,
56+
B │
57+
D │
58+
A
59+
E
60+
F
61+
D ─╯`,
6262
},
6363
{
6464
name: "with a path that has room to move to the left",
@@ -71,12 +71,12 @@ func TestRenderCommitGraph(t *testing.T) {
7171
{Sha: "6", Parents: []string{"7"}},
7272
},
7373
expectedOutput: `
74-
1
74+
1
7575
2 ⏣─╮
7676
4 │ ⏣─╮
77-
3 ─╯ │
78-
5 ───╯
79-
6 `,
77+
3 ─╯ │
78+
5 ───╯
79+
6 `,
8080
},
8181
{
8282
name: "with a new commit",
@@ -90,13 +90,13 @@ func TestRenderCommitGraph(t *testing.T) {
9090
{Sha: "6", Parents: []string{"7"}},
9191
},
9292
expectedOutput: `
93-
1
93+
1
9494
2 ⏣─╮
9595
4 │ ⏣─╮
96-
Z │ │ │
97-
3 ─╯ │ │
98-
5 ───╯ │
99-
6 ╭───╯`,
96+
Z │ │ │
97+
3 ─╯ │ │
98+
5 ───╯ │
99+
6 ╭───╯`,
100100
},
101101
{
102102
name: "with a path that has room to move to the left and continues",
@@ -109,12 +109,12 @@ func TestRenderCommitGraph(t *testing.T) {
109109
{Sha: "7", Parents: []string{"11"}},
110110
},
111111
expectedOutput: `
112-
1
112+
1
113113
2 ⏣─╮
114114
3 ⏣─│─╮
115115
5 ⏣─│─│─╮
116-
4 │ ─╯ │
117-
7 ─╯ ╭─╯`,
116+
4 │ ─╯ │
117+
7 ─╯ ╭─╯`,
118118
},
119119
{
120120
name: "with a path that has room to move to the left and continues",
@@ -128,13 +128,13 @@ func TestRenderCommitGraph(t *testing.T) {
128128
{Sha: "B", Parents: []string{"C"}},
129129
},
130130
expectedOutput: `
131-
1
131+
1
132132
2 ⏣─╮
133133
3 ⏣─│─╮
134134
5 ⏣─│─│─╮
135135
7 ⏣─│─│─│─╮
136-
4 ─┴─╯ │ │
137-
B ╭───╯ │`,
136+
4 ─┴─╯ │ │
137+
B ╭───╯ │`,
138138
},
139139
{
140140
name: "with a path that has room to move to the left and continues",
@@ -147,10 +147,10 @@ func TestRenderCommitGraph(t *testing.T) {
147147
},
148148
expectedOutput: `
149149
1 ⏣─╮
150-
3 │
150+
3 │
151151
2 ⏣─│
152152
4 ⏣─│─╮
153-
6 │ │`,
153+
6 │ │`,
154154
},
155155
{
156156
name: "new merge path fills gap before continuing path on right",
@@ -163,10 +163,10 @@ func TestRenderCommitGraph(t *testing.T) {
163163
},
164164
expectedOutput: `
165165
1 ⏣─┬─┬─╮
166-
4 │ │
167-
2 ─│─╯ │
166+
4 │ │
167+
2 ─│─╯ │
168168
A ⏣─│─╮ │
169-
B │ │ │`,
169+
B │ │ │`,
170170
},
171171
{
172172
name: "with a path that has room to move to the left and continues",
@@ -181,14 +181,14 @@ func TestRenderCommitGraph(t *testing.T) {
181181
{Sha: "C", Parents: []string{"D"}},
182182
},
183183
expectedOutput: `
184-
1
184+
1
185185
2 ⏣─╮
186186
3 ⏣─│─╮
187187
5 ⏣─│─│─╮
188188
7 ⏣─│─│─│─╮
189-
4 ─┴─╯ │ │
190-
B ╭───╯ │
191-
C │ ╭───╯`,
189+
4 ─┴─╯ │ │
190+
B ╭───╯ │
191+
C │ ╭───╯`,
192192
},
193193
{
194194
name: "with a path that has room to move to the left and continues",
@@ -205,16 +205,16 @@ func TestRenderCommitGraph(t *testing.T) {
205205
{Sha: "D", Parents: []string{"F"}},
206206
},
207207
expectedOutput: `
208-
1
208+
1
209209
2 ⏣─╮
210210
3 ⏣─│─╮
211211
5 ⏣─│─│─╮
212212
7 ⏣─│─│─│─╮
213213
8 ⏣─│─│─│─│─╮
214-
4 ─┴─╯ │ │ │
215-
B ╭───╯ │ │
216-
C │ ╭───╯ │
217-
D │ │ ╭───╯`,
214+
4 ─┴─╯ │ │ │
215+
B ╭───╯ │ │
216+
C │ ╭───╯ │
217+
D │ │ ╭───╯`,
218218
},
219219
}
220220

@@ -269,7 +269,7 @@ func TestRenderPipeSet(t *testing.T) {
269269
{fromPos: 0, toPos: 0, fromSha: "b", toSha: "c", kind: STARTS, style: green},
270270
},
271271
prevCommit: &models.Commit{Sha: "a"},
272-
expectedStr: "",
272+
expectedStr: "",
273273
expectedStyles: []style.TextStyle{green},
274274
},
275275
{
@@ -279,7 +279,7 @@ func TestRenderPipeSet(t *testing.T) {
279279
{fromPos: 0, toPos: 0, fromSha: "selected", toSha: "c", kind: STARTS, style: green},
280280
},
281281
prevCommit: &models.Commit{Sha: "a"},
282-
expectedStr: "",
282+
expectedStr: "",
283283
expectedStyles: []style.TextStyle{highlightStyle},
284284
},
285285
{
@@ -349,7 +349,7 @@ func TestRenderPipeSet(t *testing.T) {
349349
{fromPos: 2, toPos: 0, fromSha: "c1", toSha: "a2", kind: TERMINATES, style: green},
350350
},
351351
prevCommit: &models.Commit{Sha: "a1"},
352-
expectedStr: "─┴─╯",
352+
expectedStr: "─┴─╯",
353353
expectedStyles: []style.TextStyle{
354354
yellow, magenta, magenta, green, green,
355355
},
@@ -406,7 +406,7 @@ func TestRenderPipeSet(t *testing.T) {
406406
{fromPos: 0, toPos: 0, fromSha: "a2", toSha: "a3", kind: STARTS, style: yellow},
407407
},
408408
prevCommit: &models.Commit{Sha: "selected"},
409-
expectedStr: "",
409+
expectedStr: "",
410410
expectedStyles: []style.TextStyle{
411411
yellow,
412412
},
@@ -418,7 +418,7 @@ func TestRenderPipeSet(t *testing.T) {
418418
{fromPos: 1, toPos: 1, fromSha: "selected", toSha: "b3", kind: CONTINUES, style: red},
419419
},
420420
prevCommit: &models.Commit{Sha: "selected"},
421-
expectedStr: " │",
421+
expectedStr: " │",
422422
expectedStyles: []style.TextStyle{
423423
highlightStyle, nothing, highlightStyle,
424424
},
@@ -431,7 +431,7 @@ func TestRenderPipeSet(t *testing.T) {
431431
{fromPos: 2, toPos: 2, fromSha: "selected", toSha: "b3", kind: CONTINUES, style: red},
432432
},
433433
prevCommit: &models.Commit{Sha: "selected"},
434-
expectedStr: " │ │",
434+
expectedStr: " │ │",
435435
expectedStyles: []style.TextStyle{
436436
highlightStyle, nothing, green, nothing, highlightStyle,
437437
},

0 commit comments

Comments
 (0)