commit ff90e980de00e6bf7ec2f4dd8aa69f3d680927e6
parent bb3026dba86e182881e1549660f1134bc42abb86
Author: EinfachToll <istjanichtzufassen@googlemail.com>
Date: Thu, 21 Jan 2016 13:27:08 +0100
Locate the .tags file correctly on windows
Ref #184
Diffstat:
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/autoload/vimwiki/path.vim b/autoload/vimwiki/path.vim
@@ -148,3 +148,22 @@ function! vimwiki#path#is_absolute(path) "{{{
return a:path =~# '\m^/\|\~/'
endif
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
diff --git a/autoload/vimwiki/tags.vim b/autoload/vimwiki/tags.vim
@@ -141,7 +141,7 @@ endfunction " }}}
" vimwiki#tags#metadata_file_path
" Returns tags metadata file path
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 " }}}
" s:load_tags_metadata