on main help sign in
chore(messages): no need to append to a pre-allocated slice
c37fe53Christian Rocha
internal/tui/components/chat/messages/messages.go+2−2
@@ -206,7 +206,7 @@ func (m *messageCmp) renderUserMessage() string {
206 Background(t.BgSubtle)
206 Background(t.BgSubtle)
207
207
208 attachments := make([]string, len(m.message.BinaryContent()))
208 attachments := make([]string, len(m.message.BinaryContent()))
209− for _, attachment := range m.message.BinaryContent() {
209+ for i, attachment := range m.message.BinaryContent() {
210 file := filepath.Base(attachment.Path)
210 file := filepath.Base(attachment.Path)
211 var filename string
211 var filename string
212 runes := []rune(file)
212 runes := []rune(file)
@@ -218,7 +218,7 @@ func (m *messageCmp) renderUserMessage() string {
218 filename = fmt.Sprintf(" %s %s ", styles.DocumentIcon, file)
218 filename = fmt.Sprintf(" %s %s ", styles.DocumentIcon, file)
219 }
219 }
220
220
221− attachments = append(attachments, attachmentStyles.Render(filename))
221+ attachments[i] = attachmentStyles.Render(filename)
222 }
222 }
223
223
224 if len(attachments) > 0 {
224 if len(attachments) > 0 {