aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2023-09-05 10:35:30 +0200
committerRobin Jarry <robin@jarry.cc>2023-09-05 20:46:19 +0200
commit39fee6ca17fa0df8ecc25925659c4f9785c769fc (patch)
tree6c55a2089e011503c6e6b3a9e0c662ababe0b9cc
parent5991eae60b7f2de6c3377298a0ba7c2df33e02cd (diff)
downloadaerc-39fee6ca17fa0df8ecc25925659c4f9785c769fc.tar.gz
aerc-39fee6ca17fa0df8ecc25925659c4f9785c769fc.zip
compose: delete empty headers
When [compose].edit-headers=true and emptying a header in the text editor (not deleting it, only deleting its contents), the operation is ignored and the header is preserved as-is. Delete the header after exiting the text editor if the header is empty or not present. Make sure not to add empty headers. Fixes: 11e5390fa0ac ("compose: implement embedded headers in editor") Reported-by: Inwit <inwit@sindominio.net> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Inwit <inwit@sindominio.net>
-rw-r--r--widgets/compose.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/widgets/compose.go b/widgets/compose.go
index 608b8532..f7bce6d4 100644
--- a/widgets/compose.go
+++ b/widgets/compose.go
@@ -1229,14 +1229,16 @@ func (c *Composer) termClosed(err error) {
return
}
for _, h := range c.headerOrder() {
- if !embedHeader.Has(h) {
+ if embedHeader.Get(h) == "" {
// user deleted header in text editor
c.delEditor(h)
}
}
hf := embedHeader.Fields()
for hf.Next() {
- c.addEditor(hf.Key(), hf.Value(), false)
+ if hf.Value() != "" {
+ c.addEditor(hf.Key(), hf.Value(), false)
+ }
}
}