From 76b39311dc0ea6211a79d738b4fd8d335ade53fd Mon Sep 17 00:00:00 2001 From: Koni Marti Date: Mon, 11 Jul 2022 20:23:42 +0200 Subject: [PATCH] send: enter no-quit mode until message is sent Protect the sending of a message by entering the no-quit mode. This prevents aerc from exiting with the :quit command until the operation is done or the exit is forced. Signed-off-by: Koni Marti Acked-by: Robin Jarry --- commands/compose/send.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/commands/compose/send.go b/commands/compose/send.go index 574e872..dd3a8d3 100644 --- a/commands/compose/send.go +++ b/commands/compose/send.go @@ -15,6 +15,7 @@ import ( "github.com/google/shlex" "github.com/pkg/errors" + "git.sr.ht/~rjarry/aerc/commands/mode" "git.sr.ht/~rjarry/aerc/lib" "git.sr.ht/~rjarry/aerc/logging" "git.sr.ht/~rjarry/aerc/models" @@ -96,6 +97,9 @@ func (Send) Execute(aerc *widgets.Aerc, args []string) error { aerc.RemoveTab(composer) aerc.PushStatus("Sending...", 10*time.Second) + // enter no-quit mode + mode.NoQuit() + var copyBuf bytes.Buffer // for the Sent folder content if CopyTo is set failCh := make(chan error) @@ -136,6 +140,9 @@ func (Send) Execute(aerc *widgets.Aerc, args []string) error { go func() { defer logging.PanicHandler() + // leave no-quit mode + defer mode.NoQuitDone() + err = <-failCh if err != nil { aerc.PushError(strings.ReplaceAll(err.Error(), "\n", " "))