Use Unicode case folding for author search

This commit is contained in:
Andy Dixon
2026-08-27 09:37:54 +01:00
parent f20a0bea28
commit d787c4a55e
3 changed files with 24 additions and 4 deletions
+5 -3
View File
@@ -11,6 +11,7 @@ import (
"github.com/charmbracelet/bubbles/textinput"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
"golang.org/x/text/cases"
)
const (
@@ -1246,6 +1247,8 @@ func stageAuthorReplacement(commits []CommitRecord, draftByHash map[string]Commi
if replacementEmail == "" {
return 0, errors.New("replacement author email is required")
}
fold := cases.Fold()
foldedQuery := fold.String(query)
matched := 0
for _, commit := range commits {
draft, ok := draftByHash[commit.Hash]
@@ -1255,9 +1258,8 @@ func stageAuthorReplacement(commits []CommitRecord, draftByHash map[string]Commi
nameMatches := strings.EqualFold(draft.AuthorName, query)
emailMatches := strings.EqualFold(draft.AuthorEmail, query)
if !exact {
lowerQuery := strings.ToLower(query)
nameMatches = strings.Contains(strings.ToLower(draft.AuthorName), lowerQuery)
emailMatches = strings.Contains(strings.ToLower(draft.AuthorEmail), lowerQuery)
nameMatches = strings.Contains(fold.String(draft.AuthorName), foldedQuery)
emailMatches = strings.Contains(fold.String(draft.AuthorEmail), foldedQuery)
}
if !nameMatches && !emailMatches {
continue