From b2039f6abebb6055dd43f1de2376aed1d8ada9b4 Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Fri, 2 Oct 2026 09:09:55 +0200 Subject: [PATCH] fix(search): ellipsize parity matrix labels by runes, not bytes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The byte-based truncation cut through the two-byte UTF-8 sequence of Motörhead's ö, committing invalid UTF-8 into the parity README. Shared rune-based ellipsize helper; matrix regenerated. --- services/search/pkg/parity/matrix_test.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/services/search/pkg/parity/matrix_test.go b/services/search/pkg/parity/matrix_test.go index a1d51394d7..9e10a3b8a3 100644 --- a/services/search/pkg/parity/matrix_test.go +++ b/services/search/pkg/parity/matrix_test.go @@ -394,19 +394,21 @@ func matrixNames(names []string) string { } func shorten(name string) string { - if len(name) <= 24 { - return name - } - - return name[:10] + "..." + name[len(name)-8:] + return ellipsize(name, 24, 10, 8) } func shortenQuery(q string) string { - if len(q) <= 64 { - return q + return ellipsize(q, 64, 32, 24) +} + +// ellipsize truncates by runes so the cut never splits a UTF-8 sequence. +func ellipsize(s string, limit, head, tail int) string { + r := []rune(s) + if len(r) <= limit { + return s } - return q[:32] + "..." + q[len(q)-24:] + return string(r[:head]) + "..." + string(r[len(r)-tail:]) } func matrixVerdict(row *matrixResult) string {