Fix layout of options view for non-english languages

The width calculations didn't take multi-byte characters into account.
This commit is contained in:
Stefan Haller 2025-03-05 13:11:31 +01:00
parent 6a15a5915b
commit b31607250d

View file

@ -119,7 +119,8 @@ func (self *OptionsMapMgr) formatBindingInfos(bindingInfos []bindingInfo) string
plainText := fmt.Sprintf("%s: %s", info.description, info.key) plainText := fmt.Sprintf("%s: %s", info.description, info.key)
// Check if adding the next formatted string exceeds the available width // Check if adding the next formatted string exceeds the available width
if i > 0 && length+len(separator)+len(plainText) > width { textLen := utils.StringWidth(plainText)
if i > 0 && length+len(separator)+textLen > width {
builder.WriteString(theme.OptionsFgColor.Sprint(separator + ellipsis)) builder.WriteString(theme.OptionsFgColor.Sprint(separator + ellipsis))
break break
} }
@ -131,7 +132,7 @@ func (self *OptionsMapMgr) formatBindingInfos(bindingInfos []bindingInfo) string
length += len(separator) length += len(separator)
} }
builder.WriteString(formatted) builder.WriteString(formatted)
length += len(plainText) length += textLen
} }
return builder.String() return builder.String()