mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-15 00:15:32 +02:00
fix truncation
This commit is contained in:
@ -66,3 +66,19 @@ func getPadWidths(stringArrays [][]string) []int {
|
||||
}
|
||||
return padWidths
|
||||
}
|
||||
|
||||
// TruncateWithEllipsis returns a string, truncated to a certain length, with an ellipsis
|
||||
func TruncateWithEllipsis(str string, limit int) string {
|
||||
if runewidth.StringWidth(str) > limit && limit <= 3 {
|
||||
return strings.Repeat(".", limit)
|
||||
}
|
||||
return runewidth.Truncate(str, limit, "...")
|
||||
}
|
||||
|
||||
func SafeTruncate(str string, limit int) string {
|
||||
if len(str) > limit {
|
||||
return str[0:limit]
|
||||
} else {
|
||||
return str
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user