mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-15 00:15:32 +02:00
fix truncation
This commit is contained in:
@ -68,33 +68,6 @@ func ModuloWithWrap(n, max int) int {
|
||||
}
|
||||
}
|
||||
|
||||
// TruncateWithEllipsis returns a string, truncated to a certain length, with an ellipsis
|
||||
func TruncateWithEllipsis(str string, limit int) string {
|
||||
if limit == 1 && len(str) > 1 {
|
||||
return "."
|
||||
}
|
||||
|
||||
if limit == 2 && len(str) > 2 {
|
||||
return ".."
|
||||
}
|
||||
|
||||
ellipsis := "..."
|
||||
if len(str) <= limit {
|
||||
return str
|
||||
}
|
||||
|
||||
remainingLength := limit - len(ellipsis)
|
||||
return str[0:remainingLength] + "..."
|
||||
}
|
||||
|
||||
func SafeTruncate(str string, limit int) string {
|
||||
if len(str) > limit {
|
||||
return str[0:limit]
|
||||
} else {
|
||||
return str
|
||||
}
|
||||
}
|
||||
|
||||
func FindStringSubmatch(str string, regexpStr string) (bool, []string) {
|
||||
re := regexp.MustCompile(regexpStr)
|
||||
match := re.FindStringSubmatch(str)
|
||||
|
Reference in New Issue
Block a user