Locate the .tags file correctly on windows

Ref #184
This commit is contained in:
EinfachToll 2016-01-21 13:27:08 +01:00
parent bb3026dba8
commit ff90e980de
2 changed files with 20 additions and 1 deletions

View File

@ -148,3 +148,22 @@ function! vimwiki#path#is_absolute(path) "{{{
return a:path =~# '\m^/\|\~/' return a:path =~# '\m^/\|\~/'
endif endif
endfunction "}}} endfunction "}}}
" Combine a directory and a file into one path, doesn't generate duplicate
" path separator in case the directory is also having an ending / or \. This
" is because on windows ~\vimwiki//.tags is invalid but ~\vimwiki/.tags is a
" valid path.
if vimwiki#u#is_windows()
function! vimwiki#path#join_path(directory, file)
let directory = vimwiki#path#chomp_slash(a:directory)
let file = substitute(a:file, '\m^[\\/]\+', '', '')
return directory . '/' . file
endfunction
else
function! vimwiki#path#join_path(directory, file)
let directory = substitute(a:directory, '\m/\+$', '', '')
let file = substitute(a:file, '\m^/\+', '', '')
return directory . '/' . file
endfunction
endif

View File

@ -141,7 +141,7 @@ endfunction " }}}
" vimwiki#tags#metadata_file_path " vimwiki#tags#metadata_file_path
" Returns tags metadata file path " Returns tags metadata file path
function! vimwiki#tags#metadata_file_path() abort "{{{ function! vimwiki#tags#metadata_file_path() abort "{{{
return fnamemodify(VimwikiGet('path') . '/' . s:TAGS_METADATA_FILE_NAME, ':p') return fnamemodify(vimwiki#path#join_path(VimwikiGet('path'), s:TAGS_METADATA_FILE_NAME), ':p')
endfunction " }}} endfunction " }}}
" s:load_tags_metadata " s:load_tags_metadata