Use Sprint for text that isn't a format string

Two places pass plain text as the format string of TextStyle.Sprintf
without further arguments: the prefix of a disabled menu item's
tooltip, and the key binding entries of the options bar. If the text
contains a "%", for example in a translation or in a key label, it is
mangled into something like "%!(NOVERB)".

go vet doesn't report these calls yet. It will once go.mod says go
1.26, because vet then also finds printf wrappers through interface
methods. TextStyle.Sprintf forwards to the Sprintf method of the
Sprinter interface.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Stefan Haller
2026-10-16 07:53:03 +02:00
co-authored by Claude Opus 5.5
parent 9bb7ac77b2
commit c3a051dcca
2 changed files with 2 additions and 2 deletions
@@ -505,7 +505,7 @@ func (self *ConfirmationHelper) TooltipForMenuItem(menuItem *types.MenuItem) str
if tooltip != "" {
tooltip += "\n\n"
}
tooltip += style.FgRed.Sprintf(self.c.Tr.DisabledMenuItemPrefix) + menuItem.DisabledReason.Text
tooltip += style.FgRed.Sprint(self.c.Tr.DisabledMenuItemPrefix) + menuItem.DisabledReason.Text
}
return tooltip
}
+1 -1
View File
@@ -127,7 +127,7 @@ func (self *OptionsMapMgr) formatBindingInfos(bindingInfos []bindingInfo) string
break
}
formatted := info.style.Sprintf(plainText)
formatted := info.style.Sprint(plainText)
if i > 0 {
builder.WriteString(theme.OptionsFgColor.Sprint(separator))