Allow wikis in subfolders of other wikis
This commit is contained in:
parent
c8b02e4bc5
commit
b5dcd1ebeb
@ -82,18 +82,23 @@ endfunction
|
|||||||
" to any registered wiki.
|
" to any registered wiki.
|
||||||
" The path can be the full path or just the directory of the file
|
" The path can be the full path or just the directory of the file
|
||||||
function! vimwiki#base#find_wiki(path)
|
function! vimwiki#base#find_wiki(path)
|
||||||
|
let bestmatch = -1
|
||||||
|
let bestlen = 0
|
||||||
let path = vimwiki#path#path_norm(vimwiki#path#chomp_slash(a:path))
|
let path = vimwiki#path#path_norm(vimwiki#path#chomp_slash(a:path))
|
||||||
for idx in range(vimwiki#vars#number_of_wikis())
|
for idx in range(vimwiki#vars#number_of_wikis())
|
||||||
let idx_path = expand(vimwiki#vars#get_wikilocal('path', idx))
|
let idx_path = expand(vimwiki#vars#get_wikilocal('path', idx))
|
||||||
let idx_path = vimwiki#path#path_norm(vimwiki#path#chomp_slash(idx_path))
|
let idx_path = vimwiki#path#path_norm(vimwiki#path#chomp_slash(idx_path))
|
||||||
if vimwiki#path#is_equal(vimwiki#path#path_common_pfx(idx_path, path), idx_path)
|
let common_pfx = vimwiki#path#path_common_pfx(idx_path, path)
|
||||||
return idx
|
if vimwiki#path#is_equal(common_pfx, idx_path)
|
||||||
|
if len(common_pfx) > bestlen
|
||||||
|
let bestlen = len(common_pfx)
|
||||||
|
let bestmatch = idx
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
let idx += 1
|
let idx += 1
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
" an orphan page has been detected
|
return bestmatch
|
||||||
return -1
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user