Skip to content

Instantly share code, notes, and snippets.

@thinca

thinca/file.vim.diff

Created May 15, 2009
Embed
What would you like to do?
--- file.vim.old 2009-05-16 00:00:07.000000000 +0900
+++ file.vim 2009-05-15 23:56:51.000000000 +0900
@@ -79,28 +79,18 @@
return s:cached_items[cache_key]
endif
- let i = strridx(a:pattern, ku#path_separator())
- let components = split(a:pattern, ku#path_separator(), !0)
- let root_directory_pattern_p = i == 0
- let user_seems_want_dotfiles_p = components[-1][:0] == '.'
+ " 'path/to/file' -> ['path/to/', 'file']
+ let [glob_prefix, tail] = matchlist(a:pattern, '\(.*[/\\]\)\?\(.*\)')[1:2]
+ let user_seems_want_dotfiles_p = tail[:0] == '.'
" On Microsoft Windows, glob('{,.}*') doesn't list dotfiles,
" so that here we have to list dotfiles and other items separately.
let wildcards = user_seems_want_dotfiles_p ? ['*', '.?*'] : ['*']
- " glob_prefix must be followed by ku#separator() if it is not empty.
- if i < 0 " no path separator
- let glob_prefix = ''
- elseif root_directory_pattern_p
- let glob_prefix = ku#path_separator()
- else " more than one path separators
- let glob_prefix = ku#make_path(components[:-2]) . ku#path_separator()
- endif
-
let _ = []
for wildcard in wildcards
for entry in split(glob(glob_prefix . wildcard), "\n")
call add(_, {
- \ 'word': entry,
+ \ 'word': glob_prefix . fnamemodify(entry, ':t'),
\ 'menu': (isdirectory(entry) ? 'dir' : 'file'),
\ })
endfor
@@ -121,7 +111,7 @@
function! ku#file#acc_valid_p(source_name_ext, item, sep) "{{{2
- return a:sep ==# ku#path_separator() && isdirectory(a:item.word)
+ return a:sep =~# '[/\\]' && isdirectory(a:item.word)
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment