Commits

ZyX_I committed c5e041c

Added commit description cache to formatann, made these messages more brief

Comments (0)

Files changed (1)

ftplugin/aurumannotate.vim

             \            '@/mappings': '0.0',
             \        '@/autocommands': '0.0',
             \               '@/table': '0.0',})
-"▶1 formatann :: repo, hex → String
-function s:F.formatann(repo, hex)
-    let cs=a:repo.changesets[a:hex]
-    let numlen=len(len(a:repo.cslist))
-    let description=matchstr(cs.description, '\v[^\r\n]+')
-    while s:_r.strdisplaywidth(description, numlen+1)>30
-        let description=substitute(description, '.$', '', '')
-    endwhile
-    if len(description)<len(cs.description)
-        let description.='...'
+"▶1 formatann :: repo, hex, lnum → String
+function s:F.formatann(repo, hex, lnum)
+    if !has_key(self, a:hex)
+        let cs=a:repo.changesets[a:hex]
+        let numlen=len(len(a:repo.cslist))
+        let description=matchstr(cs.description, '\v[^\r\n]+')
+        while s:_r.strdisplaywidth(description, numlen+1)>30
+            let description=substitute(description, '.$', '', '')
+        endwhile
+        if len(description)<len(cs.description)
+            let description.='…'
+        endif
+        let descwidth=s:_r.strdisplaywidth(description, numlen+1)
+        if descwidth<31
+            let description.=repeat(' ', 31-descwidth)
+        endif
+        let user=substitute(cs.user, '\m\s*<[^>]\+>$', '', '')
+        let self[a:hex]=printf('%*u %s / %s', numlen, cs.rev, description, user)
     endif
-    return printf('%*u %s (by %s)', numlen, cs.rev, description, cs.user)
+    return self[a:hex]
 endfunction
 "▶1 setup
 function s:F.setup()
     let bvar=s:_r.aurum.bufvars[bufnr('%')]
     let ann=bvar.repo.functions.annotate(bvar.repo, bvar.rev, bvar.file)
     setlocal readonly
-    call map(ann, 's:F.formatann(bvar.repo, v:val)')
+    let d={}
+    call map(ann, 'call(s:F.formatann, [bvar.repo, v:val, v:key], d)')
     call setline('.', ann)
 endfunction
 let s:filetype=expand('<sfile>:t:r')