MCPcopy Create free account
hub / github.com/cli/cli / truncateMiddle

Function truncateMiddle

pkg/cmd/gpg-key/list/list.go:97–110  ·  view source on GitHub ↗
(maxWidth int, t string)

Source from the content-addressed store, hash-verified

95}
96
97func truncateMiddle(maxWidth int, t string) string {
98 if len(t) <= maxWidth {
99 return t
100 }
101
102 ellipsis := "..."
103 if maxWidth < len(ellipsis)+2 {
104 return t[0:maxWidth]
105 }
106
107 halfWidth := (maxWidth - len(ellipsis)) / 2
108 remainder := (maxWidth - len(ellipsis)) % 2
109 return t[0:halfWidth+remainder] + ellipsis + t[len(t)-halfWidth:]
110}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected