Commits

ZyX_I committed 71a2886

@%aurum/powerline: Added clearing processes when changing buffers
Fixed set_bufnr_cache

Known issue: status is displayed wrongly for the first opened buffer when
opening vim

  • Participants
  • Parent commits bcfb9ba

Comments (0)

Files changed (2)

autoload/aurum/powerline.vim

     autocmd! VimLeave * python aurum.repeatedcmd.finish()
 augroup END
 let s:_augroups+=['AuRemovePowerlineRC']
+"▶1 plswitch
+augroup AuRemovePowerlineRC
+    autocmd! BufEnter * python aurum.powerline.switch()
+augroup END
 "▶1 Python setup
 python << EOF
 aurum.powerline.sid     = str(int(vim.eval('s:_sid')))

python/aurum/powerline.py

         return funcs.branch(path)
     return Funcs(status=status, branch=branch)
 
-def generate_directories(path):
-    yield path
-    while True:
-        old_path = path
-        path = dirname(path)
-        if path == old_path:
-            break
-        yield path
-
 funcs_cache = {}
 fname_cache = {}
 
     return repo_interval
 
 def set_bufnr_cache(cache_dict, bufnr, value):
-    funcs_cache[bufnr] = (value, time())
+    cache_dict[bufnr] = (value, time())
     return value
 
 def process_repo(vim_repo):
             vcss[vcs] = Funcs(status=status_func, branch=branch_func)
         return specialize(vcss[vcs], path)
     except:
-        pass
-
-    return None
+        return None
 
 def guess():
     global funcs_cache
     if bufnr in buffers and key in buffers[bufnr]:
         rc.get(buffers[bufnr][key], now=True)
 
+def switch():
+    active_buffers = set((w.buffer.number for w in vim.windows if w.buffer.number in buffers))
+    for bufnr in buffers:
+        if bufnr not in active_buffers:
+            rcids = buffers[bufnr]['rcids']
+            for rcid in rcids.itervalues():
+                rc.remove(rcid)
+            rcids.clear()
+            buffers[bufnr].pop('funcs')
+
 def setup_buffer(bufnr, func_name, funcs=None, *args):
     if not started:
         vim.eval('FraworLoad(@%aurum/powerline)')
     if newbuffer:
         bdict = {'rcids': {}}
         buffers[bufnr] = bdict
-
-        if not funcs:
-            funcs = guess()
-
-        bdict['funcs'] = funcs
     else:
         bdict = buffers[bufnr]
-        if not funcs:
+
+    if not funcs:
+        if bdict['funcs']:
             funcs = bdict['funcs']
+        else:
+            funcs = guess()
+            bdict['funcs'] = funcs
 
     if not funcs:
         return None