Skip to content

Commit

Permalink
feat: keep same spaces between adds/deletions
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanix-Darker authored and dlvhdr committed Aug 12, 2023
1 parent 5425172 commit 8929c43
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
13 changes: 7 additions & 6 deletions ui/components/pr/pr.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,13 @@ func (pr *PullRequest) renderLines() string {
deletions = pr.Data.Deletions
}

diffs := "\033[32m+%s \033[31m-%s"
return pr.getTextStyle().Render(
fmt.Sprintf(
diffs,
components.FormatNumber(pr.Data.Additions),
components.FormatNumber(deletions),
return pr.getTextStyle().Render(
components.KeepSameSpacesOnAddDeletions(
fmt.Sprintf(
"\033[32m+%s \033[31m-%s",
components.FormatNumber(pr.Data.Additions),
components.FormatNumber(deletions),
),
),
)
}
Expand Down
5 changes: 5 additions & 0 deletions ui/components/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ import (
"github.com/dlvhdr/gh-dash/ui/context"
)

func KeepSameSpacesOnAddDeletions(str string) string {
str_as_list := strings.Split(str, " ")
return fmt.Sprintf("%7s", str_as_list[0]) + " " + fmt.Sprintf("%7s", str_as_list[1])
}

func FormatNumber(num int) string {
if num >= 1000000 {
million := float64(num) / 1000000.0
Expand Down

0 comments on commit 8929c43

Please sign in to comment.