From ecf644d66a756eeff40f558c56a44fc0edd40888 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 9 Feb 2025 11:07:13 +0000 Subject: [PATCH] fix strips emoji fixing UI Now the emoji is not visible in the commits panel. However a commit message is not changed it remains as is. This fixes the UI issue where it was distrubing the diff panel Closes #3811 fixed linting issues --- pkg/gui/presentation/commits.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/pkg/gui/presentation/commits.go b/pkg/gui/presentation/commits.go index 234a84e5c73..f0416b72cc7 100644 --- a/pkg/gui/presentation/commits.go +++ b/pkg/gui/presentation/commits.go @@ -2,6 +2,7 @@ package presentation import ( "fmt" + "regexp" "strings" "time" @@ -15,7 +16,6 @@ import ( "github.com/jesseduffield/lazygit/pkg/gui/style" "github.com/jesseduffield/lazygit/pkg/theme" "github.com/jesseduffield/lazygit/pkg/utils" - "github.com/kyokomi/emoji/v2" "github.com/samber/lo" "github.com/sasha-s/go-deadlock" "github.com/stefanhaller/git-todo-parser/todo" @@ -37,6 +37,12 @@ type bisectBounds struct { oldIndex int } +func stripEmojis(text string) string { + // This regex matches most common emoji patterns + re := regexp.MustCompile(`[\x{1F600}-\x{1F64F}]|[\x{1F300}-\x{1F5FF}]|[\x{1F680}-\x{1F6FF}]|[\x{2600}-\x{26FF}]|[\x{2700}-\x{27BF}]`) + return re.ReplaceAllString(text, "") +} + func GetCommitListDisplayStrings( common *common.Common, commits []*models.Commit, @@ -366,6 +372,7 @@ func displayCommit( bisectInfo *git_commands.BisectInfo, isYouAreHereCommit bool, ) []string { + _ = parseEmoji bisectString := getBisectStatusText(bisectStatus, bisectInfo) hashString := "" @@ -423,9 +430,8 @@ func displayCommit( if commit.Action == todo.UpdateRef { name = strings.TrimPrefix(name, "refs/heads/") } - if parseEmoji { - name = emoji.Sprint(name) - } + + name = stripEmojis(name) // Strip emojis mark := "" if isYouAreHereCommit {