1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-08-09 09:22:48 +03:00

only use a single initial for double sized runes

This commit is contained in:
Jesse Duffield
2021-10-24 15:54:20 +11:00
parent 6171690b00
commit e122f421e6
2 changed files with 21 additions and 11 deletions

View File

@@ -11,6 +11,7 @@ import (
"github.com/jesseduffield/lazygit/pkg/utils"
"github.com/kyokomi/emoji/v2"
colorful "github.com/lucasb-eyer/go-colorful"
"github.com/mattn/go-runewidth"
)
func GetCommitListDisplayStrings(commits []*models.Commit, fullDescription bool, cherryPickedCommitShaMap map[string]bool, diffName string, parseEmoji bool) [][]string {
@@ -166,19 +167,16 @@ func randFloat(hash []byte) float64 {
return float64(sum) / 100
}
var authorStyles = []style.TextStyle{
style.FgGreen,
style.FgYellow,
style.FgMagenta,
style.FgCyan,
style.FgRed,
}
func getInitials(authorName string) string {
if authorName == "" {
return authorName
}
firstRune := getFirstRune(authorName)
if runewidth.RuneWidth(firstRune) > 1 {
return string(firstRune)
}
split := strings.Split(authorName, " ")
if len(split) == 1 {
return utils.LimitStr(authorName, 2)
@@ -187,6 +185,15 @@ func getInitials(authorName string) string {
return utils.LimitStr(split[0], 1) + utils.LimitStr(split[1], 1)
}
func getFirstRune(str string) rune {
// just using the loop for the sake of getting the first rune
for _, r := range str {
return r
}
// should never land here
return 0
}
func actionColorMap(str string) style.TextStyle {
switch str {
case "pick":