Skip to content

Commit f27559e

Browse files
committed
use runes when truncating
1 parent 3d1962b commit f27559e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

cmd/docker-mcp/commands/server.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,11 +209,12 @@ func truncateString(s string, maxWidth int) string {
209209
if maxWidth <= 0 {
210210
return ""
211211
}
212-
if len(s) <= maxWidth {
212+
runes := []rune(s)
213+
if len(runes) <= maxWidth {
213214
return s
214215
}
215216
if maxWidth > 3 {
216-
return s[:maxWidth-3] + "..."
217+
return string(runes[:maxWidth-3]) + "..."
217218
}
218-
return s[:maxWidth]
219+
return string(runes[:maxWidth])
219220
}

0 commit comments

Comments
 (0)