aboutsummaryrefslogtreecommitdiffstats
path: root/commands/completion_helpers.go
diff options
context:
space:
mode:
authorTim Culverhouse <tim@timculverhouse.com>2024-10-23 08:51:01 -0500
committerRobin Jarry <robin@jarry.cc>2024-10-24 22:13:51 +0200
commit5b57d24afd4e3dec029bc32528d2d6e4dc8a3e64 (patch)
tree8bedf1ffa0a2de503f12a33b78e5859cf472dfe5 /commands/completion_helpers.go
parent1be64ef75100dd1ae4f246911e30cdb324db4f8a (diff)
downloadaerc-5b57d24afd4e3dec029bc32528d2d6e4dc8a3e64.tar.gz
textinput: make completions run async with cancellation
Make the Completer interface accept a context.Context. Provide a cancellation feature on text input tab completion to cancel an inflight completion command. This is particularly useful for address book completion if the user has specified a network-accessing command, eg carddav-query. The command is started according to the completion delay, but is cancellable if another request comes in. We also check for cancellation after the request is complete to ensure we only show valid completion results. Changelog-changed: Tab completions for text fields are run asynchronously. In-flight requests are cancelled when new input arrives. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'commands/completion_helpers.go')
-rw-r--r--commands/completion_helpers.go3
1 files changed, 2 insertions, 1 deletions
diff --git a/commands/completion_helpers.go b/commands/completion_helpers.go
index 8d293a32..6017035e 100644
--- a/commands/completion_helpers.go
+++ b/commands/completion_helpers.go
@@ -1,6 +1,7 @@
package commands
import (
+ "context"
"fmt"
"net/mail"
"strings"
@@ -30,7 +31,7 @@ func GetAddress(search string) []string {
})
if cmpl != nil {
- addrList, _ := cmpl.ForHeader("to")(search)
+ addrList, _ := cmpl.ForHeader("to")(context.Background(), search)
for _, full := range addrList {
addr, err := mail.ParseAddress(full.Value)
if err != nil {