Skip to content

Commit 6e59ecb

Browse files
chore: use strings.Builder
1 parent 8a3cd26 commit 6e59ecb

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

cli/cliui/select.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -175,21 +175,25 @@ func (m selectModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
175175
}
176176

177177
func (m selectModel) View() string {
178-
var s string
178+
var s strings.Builder
179179

180180
msg := pretty.Sprintf(pretty.Bold(), "? %s", m.message)
181181

182182
if m.selected != "" {
183183
selected := pretty.Sprint(DefaultStyles.Keyword, m.selected)
184-
s += fmt.Sprintf("%s %s\n", msg, selected)
184+
_, _ = s.WriteString(fmt.Sprintf("%s %s\n", msg, selected))
185185

186-
return s
186+
return s.String()
187187
}
188188

189189
if m.hideSearch {
190-
s += fmt.Sprintf("%s [Use arrows to move]\n", msg)
190+
_, _ = s.WriteString(fmt.Sprintf("%s [Use arrows to move]\n", msg))
191191
} else {
192-
s += fmt.Sprintf("%s %s[Use arrows to move, type to filter]\n", msg, m.search.View())
192+
_, _ = s.WriteString(fmt.Sprintf(
193+
"%s %s[Use arrows to move, type to filter]\n",
194+
msg,
195+
m.search.View(),
196+
))
193197
}
194198

195199
options, start := m.viewableOptions()
@@ -204,11 +208,11 @@ func (m selectModel) View() string {
204208
}
205209
}
206210

207-
s += pretty.Sprint(style, option)
208-
s += "\n"
211+
_, _ = s.WriteString(pretty.Sprint(style, option))
212+
_, _ = s.WriteString("\n")
209213
}
210214

211-
return s
215+
return s.String()
212216
}
213217

214218
func (m selectModel) viewableOptions() ([]string, int) {

0 commit comments

Comments
 (0)