From 39fee6ca17fa0df8ecc25925659c4f9785c769fc Mon Sep 17 00:00:00 2001 From: Robin Jarry Date: Tue, 5 Sep 2023 10:35:30 +0200 Subject: 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 Signed-off-by: Robin Jarry Tested-by: Inwit --- widgets/compose.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'widgets') 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) + } } } -- cgit