Skip to content

Commit 91e44bd

Browse files
committed
fix(ui): display cost anywhere
- Remove redundant repo name retrieval inside loop - Increment repo index correctly when repo names do not match - Set cursor to TOTAL if not in a git project [Generated by Kommit]
1 parent 56aa4ab commit 91e44bd

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

internal/ui/cost_table.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,15 @@ func NewTableModel(costs utils.Costs) Model {
4747
var totalCost float64
4848

4949
thisRepoIndex := 0
50+
repoName, _ := utils.GetRepoName()
5051
for repo, cost := range costs {
5152
rows = append(rows, table.Row{string(repo), fmt.Sprintf("%.5f", cost)})
5253
totalCost += float64(cost)
5354

54-
repoName, err := utils.GetRepoName()
55-
if err != nil {
56-
return Model{table: table.New(table.WithColumns(columns)), quit: false}
57-
}
5855
if string(repo) == repoName {
5956
thisRepoIndex = len(rows) - 1
57+
} else {
58+
thisRepoIndex++
6059
}
6160
}
6261
rows = append(rows, table.Row{"TOTAL", fmt.Sprintf("%.5f", totalCost)})

0 commit comments

Comments
 (0)