diff --git a/internal/modules/misc/handlers_test.go b/internal/modules/misc/handlers_test.go index 2daf81e..3f077bd 100644 --- a/internal/modules/misc/handlers_test.go +++ b/internal/modules/misc/handlers_test.go @@ -168,7 +168,7 @@ func TestWheelOfNames_ResultCaptionTruncatesLongResult(t *testing.T) { func TestWheelOfNames_ResultCaptionPadsShortWinnerToLongestOption(t *testing.T) { options := []string{"Bob", "Alexandria"} got := wheelResultCaption(options, 0) - want := `Result: ` + strings.Repeat(wheelCaptionPad, 3) + "Bob" + strings.Repeat(wheelCaptionPad, 4) + `` + want := `Result: ` + strings.Repeat(wheelCaptionPad, 7) + "Bob" + `` if got != want { t.Fatalf("wheelResultCaption() = %q, want %q", got, want) } diff --git a/internal/modules/misc/wheelofnames_command.go b/internal/modules/misc/wheelofnames_command.go index e1f488d..62bea5a 100644 --- a/internal/modules/misc/wheelofnames_command.go +++ b/internal/modules/misc/wheelofnames_command.go @@ -75,7 +75,7 @@ func wheelResultCaption(options []string, winner int) string { // Telegram, which would shrink the spoiler and reveal the winner's length. const wheelCaptionPad = "\u00a0" -// padWheelResultCaption centers shorter winners with blank padding so every +// padWheelResultCaption prefixes shorter winners with blank padding so every // option renders a spoiler of equal length; otherwise the spoiler width // reveals the winner. The longest option is returned unpadded. func padWheelResultCaption(options []string, result string) string { @@ -85,9 +85,7 @@ func padWheelResultCaption(options []string, result string) string { longest = n } } - missing := longest - len([]rune(result)) - left := missing / 2 - return strings.Repeat(wheelCaptionPad, left) + result + strings.Repeat(wheelCaptionPad, missing-left) + return strings.Repeat(wheelCaptionPad, longest-len([]rune(result))) + result } func truncateWheelResultCaption(result string) string {