Omnicompletion fix for Windows (#660)

* Temporary fix for omnicomplete of vimwiki links - #456.

This fixes the omnicomplete of wiki links under Windows which were
not working since paths on Windows use '\' instead of '/'. This is
a temporary fix until path refactoring is done.

* Update changelog with description of fix for #456
This commit is contained in:
Rane Brown 2019-04-20 08:28:32 -07:00 committed by Michael F. Schönitzer
parent 13adbe3510
commit 37f020d21a
3 changed files with 39 additions and 6 deletions

View File

@ -486,6 +486,10 @@ function! vimwiki#base#get_wikilinks(wiki_nr, also_absolute_links)
let result = []
for wikifile in files
let wikifile = fnamemodify(wikifile, ':r') " strip extension
if vimwiki#u#is_windows()
" TODO temporary fix see #478
let wikifile = substitute(wikifile , '/', '\', 'g')
endif
let wikifile = vimwiki#path#relpath(cwd, wikifile)
call add(result, wikifile)
endfor
@ -497,6 +501,10 @@ function! vimwiki#base#get_wikilinks(wiki_nr, also_absolute_links)
let cwd = vimwiki#vars#get_wikilocal('path') . vimwiki#vars#get_wikilocal('diary_rel_path')
endif
let wikifile = fnamemodify(wikifile, ':r') " strip extension
if vimwiki#u#is_windows()
" TODO temporary fix see #478
let wikifile = substitute(wikifile , '/', '\', 'g')
endif
let wikifile = '/'.vimwiki#path#relpath(cwd, wikifile)
call add(result, wikifile)
endfor

View File

@ -98,25 +98,48 @@ endfunction
" Returns: the relative path from a:dir to a:file
function! vimwiki#path#relpath(dir, file)
let result = []
if vimwiki#u#is_windows()
" TODO temporary fix see #478
" not sure why paths get converted back to using forward slash
" when passed to the function in the form C:\path\to\file
let dir = substitute(a:dir, '/', '\', 'g')
let file = substitute(a:file, '/', '\', 'g')
let dir = split(dir, '\')
let file = split(file, '\')
else
let dir = split(a:dir, '/')
let file = split(a:file, '/')
endif
while (len(dir) > 0 && len(file) > 0) && vimwiki#path#is_equal(dir[0], file[0])
call remove(dir, 0)
call remove(file, 0)
endwhile
if empty(dir) && empty(file)
if vimwiki#u#is_windows()
" TODO temporary fix see #478
return '.\'
else
return './'
endif
endif
for segment in dir
let result += ['..']
endfor
for segment in file
let result += [segment]
endfor
if vimwiki#u#is_windows()
" TODO temporary fix see #478
let result_path = join(result, '\')
if a:file =~ '\m\\$'
let result_path .= '\'
endif
else
let result_path = join(result, '/')
if a:file =~ '\m/$'
let result_path .= '/'
endif
endif
return result_path
endfunction

View File

@ -3347,6 +3347,8 @@ Removed:~
*
Fixed:~
* Issue #456: Omnicompletion of wikilinks under Windows. Note: this should
be considered a temporary fix until #478 is closed.
* Issue #654: Fix `:VimwikiShowVersion` command.
* PR #634: Removed extra newlines that were inserted before/after
generated links.