Skip to content

Commit

Permalink
fix: ansi: use method receiver for StringWidth
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed Oct 21, 2024
1 parent 6718bbd commit 53050cf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ansi/truncate.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ func Truncate(s string, length int, tail string) string {
// This function is aware of ANSI escape codes and will not break them, and
// accounts for wide-characters (such as East Asians and emojis).
func (m Method) Truncate(s string, length int, tail string) string {
if sw := StringWidth(s); sw <= length {
if sw := m.StringWidth(s); sw <= length {
return s
}

tw := StringWidth(tail)
tw := m.StringWidth(tail)
length -= tw
if length < 0 {
return ""
Expand Down

0 comments on commit 53050cf

Please sign in to comment.