1. ZyX_I
  2. aurum

Commits

ZyX_I  committed 515ce24

autoload/aurum, @aurum/cache: Invalidate status cache on BufWritePost event

  • Participants
  • Parent commits c6f8fda
  • Branches default

Comments (0)

Files changed (3)

File autoload/aurum.vim

View file
 "▶1 
 execute frawor#Setup('0.1', {'@aurum/repo': '4.0',
-            \               '@aurum/cache': '0.0',})
+            \               '@aurum/cache': '0.1',})
 "▶1 reltorepo
 function s:F.reltorepo(repo)
     let buf=bufnr('%')
         return {}
     endif
     let relname=s:F.reltorepo(repo)
+    augroup AuInvalidateStatusCache
+        autocmd BufWritePost <buffer> :call s:_r.cache.del('status')
+    augroup END
     return get(keys(filter(copy(s:_r.cache.get('status', repo.functions.status,
                 \                              [repo, 0, 0, [relname]],
                 \                              {})),
                 \          'index(v:val, relname)!=-1')), 0, '')
 endfunction
 let s:_functions+=['aurum#status']
+let s:_augroups+=['AuInvalidateStatusCache']
 "▶1 aurum#branch
 function aurum#branch(...)
     let repo=((a:0)?(a:1):(aurum#repository()))

File doc/aurum.txt

View file
     1.0: Removed cmdutils.prevbuf().
 autoload/aurum:
     0.1: Added |aurum#branch()| function.
+@aurum/cache:
+    0.1: Added _r.cache.del().
 
 vim: ft=help:tw=78

File plugin/aurum/cache.vim

View file
 "▶1
 scriptencoding utf-8
 if !exists('s:_pluginloaded')
-    execute frawor#Setup('0.0', {'@/resources': '0.0',
+    execute frawor#Setup('0.1', {'@/resources': '0.0',
                 \                  '@/options': '0.0',}, 0)
     finish
 elseif s:_pluginloaded
     endif
     return cbvar[a:key]
 endfunction
+"▶1 delcachedval :: key
+function s:F.delcachedval(key)
+    let buf=bufnr('%')
+    if !has_key(s:cachebvars, buf)
+        return
+    endif
+    let cbvar=s:cachebvars[buf]
+    if has_key(cbvar, a:key)
+        unlet cbvar[a:key]
+    endif
+endfunction
 "▶1 Post cache resource
-call s:_f.postresource('cache', {'get': s:F.getcachedval})
+call s:_f.postresource('cache', {'get': s:F.getcachedval,
+            \                    'del': s:F.delcachedval})
 call s:_f.postresource('cachebvars', s:cachebvars, 1)
 "▶1
 call frawor#Lockvar(s:, '_pluginloaded,cachebvars')