From 3e65bfe58aa510fe4c3efd8db8c3f7d3f0aedbaf Mon Sep 17 00:00:00 2001 From: Robin Jarry Date: Sun, 23 Jun 2024 23:06:27 +0200 Subject: completer: use AddressForHumans No need for convoluted reverse parsing of the wire format. Simply use the AddressForHumans function we already have. Signed-off-by: Robin Jarry Tested-by: Bence Ferdinandy --- completer/completer.go | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) (limited to 'completer') diff --git a/completer/completer.go b/completer/completer.go index 55559d59..5a5dea10 100644 --- a/completer/completer.go +++ b/completer/completer.go @@ -5,13 +5,13 @@ import ( "errors" "fmt" "io" - "mime" "net/mail" "os/exec" "regexp" "strings" "syscall" + "git.sr.ht/~rjarry/aerc/lib/format" "git.sr.ht/~rjarry/aerc/lib/log" "git.sr.ht/~rjarry/go-opt" ) @@ -180,22 +180,11 @@ func readCompletions(r io.Reader) ([]string, error) { if len(parts) > 1 { addr.Name = strings.TrimSpace(parts[1]) } - decoded, err := decodeMIME(addr.String()) - if err != nil { - log.Warnf("line %d: %#v: could not decode MIME string: %v", - i+1, line, err) - continue - } - completions = append(completions, decoded) + completions = append(completions, format.AddressForHumans(addr)) } return completions, tooManyLines } -func decodeMIME(s string) (string, error) { - var d mime.WordDecoder - return d.DecodeHeader(s) -} - func (c *Completer) handleErr(err error) { if c.errHandler != nil { c.errHandler(err) -- cgit