Keep the configured author styles apart from the derived ones

The styles from gui.authorColors and the ones derived from the names
of the other authors share a map, so the derived ones can't be dropped
without the configured ones. A later commit needs to drop the derived
ones on their own, when the terminal switches between dark and light.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Stefan Haller
2026-09-26 12:17:21 +02:00
co-authored by Claude Opus 5.5
parent 65efd3dde5
commit 771e75c8ab
+12 -4
View File
@@ -21,7 +21,11 @@ type authorNameCacheKey struct {
var (
authorInitialCache = make(map[string]string)
authorNameCache = make(map[authorNameCacheKey]string)
authorStyleCache = make(map[string]*style.TextStyle)
// The styles from gui.authorColors
customAuthorStyles = make(map[string]*style.TextStyle)
// The styles derived from the names of the other authors
authorStyleCache = make(map[string]*style.TextStyle)
)
const authorNameWildcard = "*"
@@ -74,12 +78,16 @@ func AuthorWithLength(authorName string, length int) string {
}
func AuthorStyle(authorName string) *style.TextStyle {
if value, ok := authorStyleCache[authorName]; ok {
if value, ok := customAuthorStyles[authorName]; ok {
return value
}
// use the unified style whatever the author name is
if value, ok := authorStyleCache[authorNameWildcard]; ok {
if value, ok := customAuthorStyles[authorNameWildcard]; ok {
return value
}
if value, ok := authorStyleCache[authorName]; ok {
return value
}
@@ -128,5 +136,5 @@ func getInitials(authorName string) string {
}
func SetCustomAuthors(customAuthorColors map[string]string) {
authorStyleCache = utils.SetCustomColors(customAuthorColors)
customAuthorStyles = utils.SetCustomColors(customAuthorColors)
}