From 10293f60d70a0aa7850fec4d613e2810735c3123 Mon Sep 17 00:00:00 2001 From: Ivan Tishchenko Date: Tue, 3 Feb 2015 13:34:07 +0400 Subject: [PATCH 1/2] Use case insensitive path comparison for vimwiki#path#relpath() --- autoload/vimwiki/path.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/vimwiki/path.vim b/autoload/vimwiki/path.vim index 67b563f..417d696 100644 --- a/autoload/vimwiki/path.vim +++ b/autoload/vimwiki/path.vim @@ -80,7 +80,7 @@ function! vimwiki#path#relpath(dir, file) "{{{ let result = [] let dir = split(a:dir, '/') let file = split(a:file, '/') - while (len(dir) > 0 && len(file) > 0) && dir[0] == file[0] + while (len(dir) > 0 && len(file) > 0) && dir[0] ==? file[0] call remove(dir, 0) call remove(file, 0) endwhile From 68b82a15c682ca3fb13b37fdaae68971a3189048 Mon Sep 17 00:00:00 2001 From: Ivan Tishchenko Date: Sat, 7 Feb 2015 01:50:04 +0300 Subject: [PATCH 2/2] Adjust case sensitivity of path comparison depending on the OS --- autoload/vimwiki/path.vim | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/autoload/vimwiki/path.vim b/autoload/vimwiki/path.vim index 417d696..fd416e0 100644 --- a/autoload/vimwiki/path.vim +++ b/autoload/vimwiki/path.vim @@ -9,6 +9,18 @@ function! vimwiki#path#chomp_slash(str) "{{{ return substitute(a:str, '[/\\]\+$', '', '') 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 function! vimwiki#path#normalize(path) "{{{ let path = a:path @@ -56,7 +68,7 @@ function! vimwiki#path#path_common_pfx(path1, path2) "{{{ let idx = 0 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 endwhile if idx == 0 @@ -80,7 +92,7 @@ function! vimwiki#path#relpath(dir, file) "{{{ let result = [] let dir = split(a:dir, '/') 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(file, 0) endwhile