aboutsummaryrefslogtreecommitdiffstats
path: root/completer/completer.go
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2024-06-23 23:06:27 +0200
committerRobin Jarry <robin@jarry.cc>2024-06-25 00:29:23 +0200
commit3e65bfe58aa510fe4c3efd8db8c3f7d3f0aedbaf (patch)
treee3139c0e10e2d0342eb5cdc852f5e6646ae6f061 /completer/completer.go
parent159746ff9ed9c3211e096f4eb390297418a30946 (diff)
downloadaerc-3e65bfe58aa510fe4c3efd8db8c3f7d3f0aedbaf.tar.gz
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 <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
Diffstat (limited to 'completer/completer.go')
-rw-r--r--completer/completer.go15
1 files changed, 2 insertions, 13 deletions
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)