Permalink
Browse files

check for unlisted buffer before switching

  • Loading branch information...
1 parent 904df79 commit f9a4ca85a6b0eb92d99e6dfdcda56a1da4a83246 @jeetsukumaran committed May 16, 2013
Showing with 12 additions and 9 deletions.
  1. +2 −2 autoload/buffergator.vim
  2. +10 −7 plugin/buffergator.vim
@@ -338,7 +338,7 @@ endfunction!
function! s:_find_mru_bufnr(dir)
let l:cur_buf_idx = index(w:buffergator_mru, bufnr("%"))
- if len(w:buffergator_mru) < 2
+ if len(w:buffergator_mru) < 1 " maybe should be 2?
return bufnr("%")
endif
if l:cur_buf_idx < 0
@@ -366,7 +366,7 @@ function! s:_find_mru_bufnr(dir)
endif
endif
let l:target_bufnr = w:buffergator_mru[l:target_buf_idx]
- if !bufexists(l:target_bufnr)
+ if !bufexists(l:target_bufnr) || !buflisted(l:target_bufnr)
call remove(w:buffergator_mru, l:target_buf_idx)
return s:_find_mru_bufnr(a:dir)
else
@@ -39,10 +39,12 @@ endif
let g:buffergator_track_mru = 1
let g:buffergator_mru = []
function! BuffergatorUpdateMRU(acmd_bufnr)
- if len(g:buffergator_mru) < 2
+ if len(g:buffergator_mru) < 1 " maybe should be 2?
if g:buffergator_mru_cycle_loop
+ let g:buffergator_mru = []
for l:bni in range(bufnr("$"), 1, -1)
- if buflisted(l:bni) && getbufvar(l:bni, "current_syntax") !~ ".*netrw.*"
+ if buflisted(l:bni)
+ \ && getbufvar(l:bni, "&filetype") != "netrw"
call add(g:buffergator_mru, l:bni)
endif
endfor
@@ -53,7 +55,8 @@ function! BuffergatorUpdateMRU(acmd_bufnr)
endif
if g:buffergator_track_mru
let bnum = a:acmd_bufnr + 0
- if bnum == 0 || !buflisted(bnum)
+ " if bnum == 0 || !buflisted(bnum) || !(empty(getbufvar(bnum, "netrw_browser_active")))
+ if bnum == 0 || !buflisted(bnum) || getbufvar(bnum, "&filetype") == "netrw"
return
endif
call filter(g:buffergator_mru, 'v:val !=# bnum')
@@ -64,11 +67,11 @@ function! BuffergatorUpdateMRU(acmd_bufnr)
endfunction
" Autocommands that update the most recenly used buffers
-augroup BufferGatorMRU
+augroup BuffergatorMRU
au!
-autocmd BufEnter * call BuffergatorUpdateMRU(expand('<abuf>'))
-autocmd BufRead * call BuffergatorUpdateMRU(expand('<abuf>'))
-autocmd BufNewFile * call BuffergatorUpdateMRU(expand('<abuf>'))
+autocmd BufEnter * call BuffergatorUpdateMRU(expand('<abuf>'))
+autocmd BufRead * call BuffergatorUpdateMRU(expand('<abuf>'))
+autocmd BufNewFile * call BuffergatorUpdateMRU(expand('<abuf>'))
autocmd BufWritePost * call BuffergatorUpdateMRU(expand('<abuf>'))
augroup NONE

0 comments on commit f9a4ca8

Please sign in to comment.