Browse Source

Test for an empty viminfo file

Marco Hinz 12 years ago
parent
commit
a576a6370a
1 changed files with 22 additions and 20 deletions
  1. 22 20
      autoload/startify.vim

+ 22 - 20
autoload/startify.vim

@@ -217,30 +217,32 @@ function! s:show_files(cnt) abort
   let num     = s:numfiles
   let entries = {}
 
-  for fname in v:oldfiles
-    let fullpath = resolve(fnamemodify(fname, ':p'))
-
-    " filter duplicates, bookmarks and entries from the skiplist
-    if has_key(entries, fullpath)
-          \ || !filereadable(fullpath)
-          \ || (exists('g:startify_skiplist')  && s:is_in_skiplist(fullpath))
-          \ || (exists('g:startify_bookmarks') && s:is_bookmark(fullpath))
-      continue
-    endif
+  if !empty(v:oldfiles)
+    for fname in v:oldfiles
+      let fullpath = resolve(fnamemodify(fname, ':p'))
+
+      " filter duplicates, bookmarks and entries from the skiplist
+      if has_key(entries, fullpath)
+            \ || !filereadable(fullpath)
+            \ || (exists('g:startify_skiplist')  && s:is_in_skiplist(fullpath))
+            \ || (exists('g:startify_bookmarks') && s:is_bookmark(fullpath))
+        continue
+      endif
 
-    let entries[fullpath] = 1
-    let index = s:get_index_as_string(cnt)
+      let entries[fullpath] = 1
+      let index = s:get_index_as_string(cnt)
 
-    call append('$', '   ['. index .']'. repeat(' ', (3 - strlen(index))) . fname)
-    execute 'nnoremap <buffer>' index ':edit' fnameescape(fname) s:cmd
+      call append('$', '   ['. index .']'. repeat(' ', (3 - strlen(index))) . fname)
+      execute 'nnoremap <buffer>' index ':edit' fnameescape(fname) s:cmd
 
-    let cnt += 1
-    let num -= 1
+      let cnt += 1
+      let num -= 1
 
-    if !num
-      break
-    endif
-  endfor
+      if !num
+        break
+      endif
+    endfor
+  endif
 
   return cnt
 endfunction