all repos — honk @ 6b431fc97646d752ba244f696a12d68c8f2c9726

my fork of honk

we may need to expand short mentions more than once
Ted Unangst tedu@tedunangst.com
Thu, 10 Oct 2019 18:48:03 -0400
commit

6b431fc97646d752ba244f696a12d68c8f2c9726

parent

9c7f3569ee2cfcd7848912430f150f30c97f375c

1 files changed, 25 insertions(+), 18 deletions(-)

jump to
M fun.gofun.go

@@ -329,27 +329,34 @@

var re_quickmention = regexp.MustCompile("(^| )@[[:alnum:]]+ ") func quickrename(s string, userid int64) string { - return re_quickmention.ReplaceAllStringFunc(s, func(m string) string { - prefix := "" - if m[0] == ' ' { - prefix = " " + nonstop := true + for nonstop { + nonstop = false + s = re_quickmention.ReplaceAllStringFunc(s, func(m string) string { + log.Printf("m: %s", m) + prefix := "" + if m[0] == ' ' { + prefix = " " + m = m[1:] + } + prefix += "@" m = m[1:] - } - prefix += "@" - m = m[1:] - m = m[:len(m)-1] + m = m[:len(m)-1] - row := stmtOneHonker.QueryRow(m, userid) - var xid string - err := row.Scan(&xid) - if err == nil { - _, name := handles(xid) - if name != "" { - m = name + row := stmtOneHonker.QueryRow(m, userid) + var xid string + err := row.Scan(&xid) + if err == nil { + _, name := handles(xid) + if name != "" { + nonstop = true + m = name + } } - } - return prefix + m + " " - }) + return prefix + m + " " + }) + } + return s } func mentionize(s string) string {