Skip to content

Commit

Permalink
Modifies to measure file name width in runes to support utf8
Browse files Browse the repository at this point in the history
  • Loading branch information
cskeeters committed Feb 25, 2025
1 parent b6a8bdf commit 3436b31
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions view.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"sort"
"strconv"
"strings"
"unicode/utf8"

"github.com/charmbracelet/lipgloss"
)
Expand Down Expand Up @@ -303,8 +304,8 @@ func (m *model) generateContent() string {
maxNameWidth = maxNameWidth - 6 - 6
}
name := truncateFileName(f.Name(), maxNameWidth)
nameWidth := len(name)
spaceWidth := maxNameWidth - nameWidth
nameWidth := utf8.RuneCountInString(name)
spaceWidth := maxNameWidth - nameWidth - 1

text := fmt.Sprintf("%s %-"+strconv.Itoa(nameWidth)+"s", icon, name)
space := ""
Expand Down

0 comments on commit 3436b31

Please sign in to comment.