Issue #1 wontfix

File isn't added to the buffer list after :bd and re-opening

Anonymous created an issue

If I remove a buffer with :bd and try to re-open the same file with FuzzyFinder, it shows the file, but the file doesn't show up in the buffer list.

Comments (24)

  1. Anonymous

    Hi, Sorry for the late response.

    It's not a bug. Fuzzyfinder filters out unlisted buffers because they include temporary buffers. Use :quit/:close instead of :bdelete if the buffer is likely to be re-opened.

  2. Takeshi NISHIDA repo owner

    Hi, Sorry for the late response.

    It's not a bug. Fuzzyfinder filters out unlisted buffers because they include temporary buffers. Use :quit/:close instead of :bdelete if the buffer is likely to be re-opened.

  3. jgallen23

    This used to work fine with the old version of fuzzyfinder. I could use :bd and then sometime later in the session, open up that same file and it would show up in my minibufexplorer. I frequently like to close all my buffers in a session just to clean up my tabs. When I do that, fuzzy finder won't actually open any of the files that were open already. This seems like a bug to me.

  4. Takeshi NISHIDA repo owner

    It seems very special usage. Try the following patch:

    diff -r 15277bf66e23 plugin/fuzzyfinder.vim
    --- a/plugin/fuzzyfinder.vim
    +++ b/plugin/fuzzyfinder.vim
    @@ -860,7 +860,7 @@
     "
     function! g:FuzzyFinderMode.Buffer.on_mode_enter_post()
       let self.items = map(filter(range(1, bufnr('$')),
    -        \                     'buflisted(v:val) && v:val != self.prev_bufnr'),
    +        \                     'bufexists(v:val) && v:val != self.prev_bufnr'),
             \              'self.make_item(v:val)')
       if self.mru_order
         call s:MapToSetSerialIndex(sort(self.items, 's:CompareTimeDescending'), 1)
    
  5. jgallen23

    Thanks. A weird thing happened though and I might just not have noticed it before, but the files show up in the fuzzy finder buffer list, but they don't show up in the vim buffer list. So if I use the FFBuffer all my files that I :bd and re-open show up there, but they don't show up in the vim buffer list. Does fuzzyfinder have a separate buffer list?

  6. jgallen23

    I reverted back the patch and it looks like this was caused just from the patch. It also looks like all files that were :bd (and not re-opened) stay in the FFBuffer with that patch

  7. Takeshi NISHIDA repo owner

    Sorry, but I don't understand what is VIM BUFFER LIST you call and what you want. Have you read help :buffers and unlisted-buffer? That patch changes fuzzyfinder to show a buffer list like :buffers! instead of :buffers.

  8. jgallen23

    I was able to fix it on my end by changing line 519 (not sure how to do that sweet diff you did) from let buf_nr = bufnr('^' . a:path . '$') if buf_nr > -1 to let buf_nr = buflisted('^' . a:path . '$') if buf_nr > 0

  9. Takeshi NISHIDA repo owner

    I understood. This is probably correct patch:

    diff -r 0846d5908de9 plugin/fuzzyfinder.vim
    --- a/plugin/fuzzyfinder.vim
    +++ b/plugin/fuzzyfinder.vim
    @@ -506,18 +506,23 @@
             \         s:MoveToWindowOfBufferInOtherTabPage(a:buf_nr)))
         return
       endif
    -  execute printf({
    -        \   s:OPEN_MODE_CURRENT : ':%sbuffer'           ,
    -        \   s:OPEN_MODE_SPLIT   : ':%ssbuffer'          ,
    -        \   s:OPEN_MODE_VSPLIT  : ':vertical :%ssbuffer',
    -        \   s:OPEN_MODE_TAB     : ':tab :%ssbuffer'     ,
    -        \ }[a:mode], a:buf_nr)
    +  if !buflisted(a:buf_nr)
    +    call s:OpenFile(bufname(a:buf_nr), a:mode, a:reuse)
    +  else
    +    execute printf({
    +          \   s:OPEN_MODE_CURRENT : ':%sbuffer'           ,
    +          \   s:OPEN_MODE_SPLIT   : ':%ssbuffer'          ,
    +          \   s:OPEN_MODE_VSPLIT  : ':vertical :%ssbuffer',
    +          \   s:OPEN_MODE_TAB     : ':tab :%ssbuffer'     ,
    +          \ }[a:mode], a:buf_nr)
    +
    +  endif
     endfunction
     
     "
     function! s:OpenFile(path, mode, reuse)
       let buf_nr = bufnr('^' . a:path . '$')
    -  if buf_nr > -1
    +  if buf_nr > -1 && buflisted(buf_nr)
         call s:OpenBuffer(buf_nr, a:mode, a:reuse)
       else
         execute {
    @@ -861,7 +866,7 @@
     "
     function! g:FuzzyFinderMode.Buffer.on_mode_enter_post()
       let self.items = map(filter(range(1, bufnr('$')),
    -        \                     'buflisted(v:val) && v:val != self.prev_bufnr'),
    +        \                     'bufexists(v:val) && v:val != self.prev_bufnr'),
             \              'self.make_item(v:val)')
       if self.mru_order
         call s:MapToSetSerialIndex(sort(self.items, 's:CompareTimeDescending'), 1)
    

    And this is diff markup. (You must remove leading spaces.)

      {{{
      #!diff
      
      - foo
      + bar
     
      }}}
    
  10. Sean Lynch
    • changed status to open

    Is there a patch after the changes made in 3.0?

    Took me a while to figure out what was happening (and find this bug), as I find this rather annoying (I delete buffers a lot to manage what I have open/memory, and reopen them later in the same session)

  11. Chris Chambers

    I agree with techniq/jgallen23, and don't think this is a particularly special/rare usage: in an extended vim programming session, I might open and :bd a given buffer multiple times. I had noticed the same behaviour, and until lately have resorted to closing/reopening the vim session as a workaround.

    To most users with the same style and workflow, this feels like a bug. Perhaps it would be better to introduce a global variable which toggles this patched behaviour on/off, rather than leaving it buried in the issues list?

  12. Chris Chambers

    This patch provides a relatively simple workaround: it disables the 'reuse' option, which ensures that buffers you close via :bd won't be unlisted.

    For the latest fuzzyfinder (3.5):

    diff --git a/.vim/autoload/fuf.vim b/.vim/autoload/fuf.vim
    index dccfa46..1783322 100644
    --- a/.vim/autoload/fuf.vim
    +++ b/.vim/autoload/fuf.vim
    @@ -216,16 +216,16 @@ endfunction
     "
     function fuf#openFile(path, mode, reuse)
       let bufNr = bufnr('^' . a:path . '$')
    -  if bufNr > -1
    -    call fuf#openBuffer(bufNr, a:mode, a:reuse)
    -  else
    +  " if bufNr > -1
    +  "   call fuf#openBuffer(bufNr, a:mode, a:reuse)
    +  " else
         execute {
               \   s:OPEN_TYPE_CURRENT : 'edit '   ,
               \   s:OPEN_TYPE_SPLIT   : 'split '  ,
               \   s:OPEN_TYPE_VSPLIT  : 'vsplit ' ,
               \   s:OPEN_TYPE_TAB     : 'tabedit ',
               \ }[a:mode] . fnameescape(fnamemodify(a:path, ':~:.'))
    -  endif
    +  " endif
     endfunction
     
     "
    

    For version 2.22.3 (compatible with fuzzyfinder-textmate):

    diff --git a/.vim/plugin/fuzzyfinder.vim b/.vim/plugin/fuzzyfinder.vim
    index a717bfd..3aaf159 100644
    --- a/.vim/plugin/fuzzyfinder.vim
    +++ b/.vim/plugin/fuzzyfinder.vim
    @@ -517,16 +517,16 @@ endfunction
     "
     function! s:OpenFile(path, mode, reuse)
       let buf_nr = bufnr('^' . a:path . '$')
    -  if buf_nr > -1
    -    call s:OpenBuffer(buf_nr, a:mode, a:reuse)
    -  else
    +  " if buf_nr > -1
    +  "   call s:OpenBuffer(buf_nr, a:mode, a:reuse)
    +  " else
         execute {
               \   s:OPEN_MODE_CURRENT : ':edit '   ,
               \   s:OPEN_MODE_SPLIT   : ':split '  ,
               \   s:OPEN_MODE_VSPLIT  : ':vsplit ' ,
               \   s:OPEN_MODE_TAB     : ':tabedit ',
               \ }[a:mode] . s:EscapeFilename(a:path)
    -  endif
    +  " endif
     endfunction
     
     "
    
  13. adamlogic

    I'll chime in here with my own patch. I'm still confused, though, why this is not considered a bug. The problem is not that fuzzyfinder filters out unlisted buffers. The problem is that when an unlisted buffer is re-opened, it is not set to listed. My patch doesn't really accomplish that either because I don't fully understand how fuzzyfinder reuses existing buffers. Seems to work for me so far, though.

    https://github.com/edgecase/vim-fuzzyfinder/commit/7c105a2e92b28c6c8b0a49e9468837844a118632

  14. Anonymous

    I agree. When I open a file in fuzzy finder, I want the file to be LISTED again. This is a bug.

    --Nate

  15. Anonymous

    I'm learning VIM from Peepcode screencasts and one of the first introductions to buffers is using the ":ls" command. I really like FuzzyFinder (coming from TextMate) but this seems like a problem wrt the basic, intended design of vim and its use of buffers. Yes I am new but feels like a bug here too.

    Takeshi, I understand your view and suggest making the current behaviour as an option and default to having fuzzy_finder maintain the buffer list per vim's default behaviour.

    HTH, Greg

  16. Anonymous

    Oops the "works nicely" was to adamlogic for his patch. ":ls" behaves as expected after opening a series of files with fuzzy_finder.

    -Greg

  17. Anonymous

    #42 is a duplicate of this, and yes, this is a bug. Reopening a file with FuzzyFinder should be similar to ":e file" which does set buflisted.

    Please fix this.

  18. Anonymous

    :quit or :close are not suitable replacements for :bdelete. They close the window, messing up what could be a carefully created arrangement of windows. Often I just want to close the buffer, but keep the same window configuration. ":bdelete" is the only command that does this.

  19. Ory Band

    I am too have a working-flow like the one listed here. And I am too am frustrated about FF not displaying/opening my re-opened buffers.

    +1 for applying this patch as a global toggable option in FF.

  20. Log in to comment