Merge pull request #112 from t7ko/completion-fix-issue111

Use case sensitive/insensitive path comparison depending on the OS
This commit is contained in:
EinfachToll 2015-02-09 09:18:21 +01:00
commit bf1eb62c32

View File

@ -9,6 +9,18 @@ function! vimwiki#path#chomp_slash(str) "{{{
return substitute(a:str, '[/\\]\+$', '', '') return substitute(a:str, '[/\\]\+$', '', '')
endfunction "}}} endfunction "}}}
" Define path-compare function, either case-sensitive or not, depending on OS.
"{{{ " function! vimwiki#path#is_equal(p1, p2)
if has('win32')
function! vimwiki#path#is_equal(p1, p2)
return a:p1 ==? a:p2
endfunction
else
function! vimwiki#path#is_equal(p1, p2)
return a:p1 == a:p2
endfunction
endif "}}}
" collapse sections like /a/b/../c to /a/c " collapse sections like /a/b/../c to /a/c
function! vimwiki#path#normalize(path) "{{{ function! vimwiki#path#normalize(path) "{{{
let path = a:path let path = a:path
@ -56,7 +68,7 @@ function! vimwiki#path#path_common_pfx(path1, path2) "{{{
let idx = 0 let idx = 0
let minlen = min([len(p1), len(p2)]) let minlen = min([len(p1), len(p2)])
while (idx < minlen) && (p1[idx] ==? p2[idx]) while (idx < minlen) && vimwiki#path#is_equal(p1[idx], p2[idx])
let idx = idx + 1 let idx = idx + 1
endwhile endwhile
if idx == 0 if idx == 0
@ -80,7 +92,7 @@ function! vimwiki#path#relpath(dir, file) "{{{
let result = [] let result = []
let dir = split(a:dir, '/') let dir = split(a:dir, '/')
let file = split(a:file, '/') let file = split(a:file, '/')
while (len(dir) > 0 && len(file) > 0) && dir[0] == file[0] while (len(dir) > 0 && len(file) > 0) && vimwiki#path#is_equal(dir[0], file[0])
call remove(dir, 0) call remove(dir, 0)
call remove(file, 0) call remove(file, 0)
endwhile endwhile