From 0ceea02720bcebb7e672b42cc72b2e8ce117ada8 Mon Sep 17 00:00:00 2001 From: Kevin Kuehler Date: Sat, 3 Aug 2019 17:23:08 -0700 Subject: cc/bcc: Append to existing headers if called twice Signed-off-by: Kevin Kuehler --- commands/compose/cc-bcc.go | 4 ++-- widgets/compose.go | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/commands/compose/cc-bcc.go b/commands/compose/cc-bcc.go index 7bc1f5d..864bb8e 100644 --- a/commands/compose/cc-bcc.go +++ b/commands/compose/cc-bcc.go @@ -30,9 +30,9 @@ func (_ CC) Execute(aerc *widgets.Aerc, args []string) error { switch args[0] { case "cc": - composer.AddEditor("Cc", addrs) + composer.AddEditor("Cc", addrs, true) case "bcc": - composer.AddEditor("Bcc", addrs) + composer.AddEditor("Bcc", addrs, true) } return nil diff --git a/widgets/compose.go b/widgets/compose.go index e2615ed..936da14 100644 --- a/widgets/compose.go +++ b/widgets/compose.go @@ -10,6 +10,7 @@ import ( "os" "os/exec" "path/filepath" + "strings" "time" "github.com/emersion/go-message" @@ -509,8 +510,12 @@ func (c *Composer) NextField() { } // AddEditor appends a new header editor to the compose window. -func (c *Composer) AddEditor(header string, value string) { +func (c *Composer) AddEditor(header string, value string, appendHeader bool) { if _, ok := c.editors[header]; ok { + if appendHeader { + header := c.editors[header].input.String() + value = strings.TrimSpace(header) + ", " + value + } c.editors[header].input.Set(value) return } -- cgit v1.2.3