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
This commit is contained in:
root 2025-02-09 11:07:13 +00:00
parent a5698b86fa
commit ecf644d66a

View file

@ -2,6 +2,7 @@ package presentation
import ( import (
"fmt" "fmt"
"regexp"
"strings" "strings"
"time" "time"
@ -15,7 +16,6 @@ import (
"github.com/jesseduffield/lazygit/pkg/gui/style" "github.com/jesseduffield/lazygit/pkg/gui/style"
"github.com/jesseduffield/lazygit/pkg/theme" "github.com/jesseduffield/lazygit/pkg/theme"
"github.com/jesseduffield/lazygit/pkg/utils" "github.com/jesseduffield/lazygit/pkg/utils"
"github.com/kyokomi/emoji/v2"
"github.com/samber/lo" "github.com/samber/lo"
"github.com/sasha-s/go-deadlock" "github.com/sasha-s/go-deadlock"
"github.com/stefanhaller/git-todo-parser/todo" "github.com/stefanhaller/git-todo-parser/todo"
@ -37,6 +37,12 @@ type bisectBounds struct {
oldIndex int 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( func GetCommitListDisplayStrings(
common *common.Common, common *common.Common,
commits []*models.Commit, commits []*models.Commit,
@ -366,6 +372,7 @@ func displayCommit(
bisectInfo *git_commands.BisectInfo, bisectInfo *git_commands.BisectInfo,
isYouAreHereCommit bool, isYouAreHereCommit bool,
) []string { ) []string {
_ = parseEmoji
bisectString := getBisectStatusText(bisectStatus, bisectInfo) bisectString := getBisectStatusText(bisectStatus, bisectInfo)
hashString := "" hashString := ""
@ -423,9 +430,8 @@ func displayCommit(
if commit.Action == todo.UpdateRef { if commit.Action == todo.UpdateRef {
name = strings.TrimPrefix(name, "refs/heads/") name = strings.TrimPrefix(name, "refs/heads/")
} }
if parseEmoji {
name = emoji.Sprint(name) name = stripEmojis(name) // Strip emojis
}
mark := "" mark := ""
if isYouAreHereCommit { if isYouAreHereCommit {