diff options
author | Robin Jarry <robin@jarry.cc> | 2023-10-24 22:24:00 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-10-25 09:25:18 +0200 |
commit | 2d9654df229b97237cd9a9157ac96d89c5ce2630 (patch) | |
tree | 0ef9bef2ba0f490e79edea03f8b3e2580086c989 /app | |
parent | 4ceafd0b7b71bd934a0f15c1139ed74d0a518b70 (diff) | |
download | aerc-2d9654df229b97237cd9a9157ac96d89c5ce2630.tar.gz |
compose: fix header navigation after :compose -e
When the terminal is closed with [compose].edit-headers=true, all
headers are deleted and recreated based on the email content.
Since the terminal is not active, adding the first header was working
fine, but the next ones were replacing the single entry on each call of
addEditor().
Fix the broken append() logic.
Reported-by: Inwit <inwit@sindominio.net>
Fixes: c2a4fc7fdfae ("compose: avoid panic when deleting the last header")
Changelog-fixed: Selection of headers in composer after `:compose -e`
followed by `:edit -E`.
Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Inwit <inwit@sindominio.net>
Diffstat (limited to 'app')
-rw-r--r-- | app/compose.go | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/app/compose.go b/app/compose.go index 76f28881..fdc993ed 100644 --- a/app/compose.go +++ b/app/compose.go @@ -1413,21 +1413,16 @@ func (c *Composer) addEditor(header string, value string, appendHeader bool) str } c.editors[header] = e c.layout = append(c.layout, []string{header}) - switch { - case len(c.focusable) == 0: - c.focusable = []ui.MouseableDrawableInteractive{e} - case c.editor != nil: + if len(c.focusable) == 0 || c.editor == nil { + // no terminal editor, insert at the end + c.focusable = append(c.focusable, e) + } else { // Insert focus of new editor before terminal editor c.focusable = append( c.focusable[:len(c.focusable)-1], e, c.focusable[len(c.focusable)-1], ) - default: - c.focusable = append( - c.focusable[:len(c.focusable)-1], - e, - ) } editor = e } |