Commits

Anonymous committed 34bd0bf

Fixed a bug that an error occurs when nonexistent buffer-name was entered in Buffer mode.

Comments (0)

Files changed (1)

plugin/fuzzyfinder.vim

 " ChangeLog:
 "   2.14:
 "     - Changed to show buffer status in Buffer mode.
-"     - Added 'enumerating_limit' option.
+"     - Fixed a bug that an error occurs when nonexistent buffer-name was
+"       entered in Buffer mode. Thanks Maxim Kim.
+"     - Added 'enumerating_limit' option. Thanks id:secondlife.
 "     - Removed 'matching_limit' option. Use 'enumerating_limit' instead.
 "     - TODO
 "
 endfunction
 
 function! g:FuzzyFinderMode.Buffer.on_open(expr, mode)
-  " attempts to convert the path to the number for handling unnamed buffer
+  " filter the selected item to get the buffer number for handling unnamed buffer
+  call filter(self.cache, 'v:val.path == a:expr')
+  if empty(self.cache)
+    return ''
+  endif
   return printf([
         \   ':%sbuffer',
         \   ':%ssbuffer',
         \   ':vertical :%ssbuffer',
         \   ':tab :%ssbuffer',
-        \ ][a:mode] . "\<CR>", filter(self.cache, 'v:val.path == a:expr')[0].buf_nr)
+        \ ][a:mode] . "\<CR>", self.cache[0].buf_nr)
 endfunction
 
 function! g:FuzzyFinderMode.Buffer.on_mode_enter()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.