@@ -39,6 +39,9 @@ var (
39 errClipboardUnknownFormat = fmt.Errorf("unknown clipboard format")
39 errClipboardUnknownFormat = fmt.Errorf("unknown clipboard format")
42+// If pasted text has more than 10 newlines, treat it as a file attachment.
43+const pasteLinesThreshold = 10
42type Editor interface {
45type Editor interface {
43 util.Model
46 util.Model
44 layout.Sizeable
47 layout.Sizeable
@@ -239,8 +242,7 @@ func (m *editorCmp) Update(msg tea.Msg) (util.Model, tea.Cmd) {
239 m.textarea.SetValue(msg.Text)
242 m.textarea.SetValue(msg.Text)
240 m.textarea.MoveToEnd()
243 m.textarea.MoveToEnd()
241 case tea.PasteMsg:
244 case tea.PasteMsg:
242− // If pasted text has more than 2 newlines, treat it as a file attachment.
243− if strings.Count(msg.Content, "\n") > 2 {
245+ if strings.Count(msg.Content, "\n") > pasteLinesThreshold {
244 content := []byte(msg.Content)
246 content := []byte(msg.Content)
245 if len(content) > maxAttachmentSize {
247 if len(content) > maxAttachmentSize {
246 return m, util.ReportWarn("Paste is too big (>5mb)")
248 return m, util.ReportWarn("Paste is too big (>5mb)")