From 5f5514d8742c803e5c0b701e3d6c053624687f70 Mon Sep 17 00:00:00 2001 From: Moritz Poldrack Date: Fri, 26 May 2023 10:22:47 +0200 Subject: compose: quit composing when editor returns error When the editor crashes, or the user forces it to exit with an error code, it is safe to assume that they can't (if the command failed) or don't want to (if :cq'd) continue composing a meaningful message. Suggested-by: tristan957 Signed-off-by: Moritz Poldrack Acked-by: Robin Jarry --- widgets/compose.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'widgets') diff --git a/widgets/compose.go b/widgets/compose.go index ea6a50a4..43657a29 100644 --- a/widgets/compose.go +++ b/widgets/compose.go @@ -1022,6 +1022,12 @@ func (c *Composer) termClosed(err error) { if c.editor == nil { return } + if c.editor.cmd.ProcessState.ExitCode() > 0 { + c.Close() + c.aerc.RemoveTab(c, true) + c.aerc.PushError("Editor exited with error. Compose aborted!") + return + } c.grid.RemoveChild(c.editor) c.review = newReviewMessage(c, err) c.grid.AddChild(c.review).At(3, 0) -- cgit