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:
parent
13adbe3510
commit
37f020d21a
@ -486,6 +486,10 @@ function! vimwiki#base#get_wikilinks(wiki_nr, also_absolute_links)
|
|||||||
let result = []
|
let result = []
|
||||||
for wikifile in files
|
for wikifile in files
|
||||||
let wikifile = fnamemodify(wikifile, ':r') " strip extension
|
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)
|
let wikifile = vimwiki#path#relpath(cwd, wikifile)
|
||||||
call add(result, wikifile)
|
call add(result, wikifile)
|
||||||
endfor
|
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')
|
let cwd = vimwiki#vars#get_wikilocal('path') . vimwiki#vars#get_wikilocal('diary_rel_path')
|
||||||
endif
|
endif
|
||||||
let wikifile = fnamemodify(wikifile, ':r') " strip extension
|
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)
|
let wikifile = '/'.vimwiki#path#relpath(cwd, wikifile)
|
||||||
call add(result, wikifile)
|
call add(result, wikifile)
|
||||||
endfor
|
endfor
|
||||||
|
@ -98,25 +98,48 @@ endfunction
|
|||||||
" Returns: the relative path from a:dir to a:file
|
" Returns: the relative path from a:dir to a:file
|
||||||
function! vimwiki#path#relpath(dir, file)
|
function! vimwiki#path#relpath(dir, file)
|
||||||
let result = []
|
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 dir = split(a:dir, '/')
|
||||||
let file = split(a:file, '/')
|
let file = split(a:file, '/')
|
||||||
|
endif
|
||||||
while (len(dir) > 0 && len(file) > 0) && vimwiki#path#is_equal(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
|
||||||
if empty(dir) && empty(file)
|
if empty(dir) && empty(file)
|
||||||
|
if vimwiki#u#is_windows()
|
||||||
|
" TODO temporary fix see #478
|
||||||
|
return '.\'
|
||||||
|
else
|
||||||
return './'
|
return './'
|
||||||
endif
|
endif
|
||||||
|
endif
|
||||||
for segment in dir
|
for segment in dir
|
||||||
let result += ['..']
|
let result += ['..']
|
||||||
endfor
|
endfor
|
||||||
for segment in file
|
for segment in file
|
||||||
let result += [segment]
|
let result += [segment]
|
||||||
endfor
|
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, '/')
|
let result_path = join(result, '/')
|
||||||
if a:file =~ '\m/$'
|
if a:file =~ '\m/$'
|
||||||
let result_path .= '/'
|
let result_path .= '/'
|
||||||
endif
|
endif
|
||||||
|
endif
|
||||||
return result_path
|
return result_path
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
@ -3347,6 +3347,8 @@ Removed:~
|
|||||||
*
|
*
|
||||||
|
|
||||||
Fixed:~
|
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.
|
* Issue #654: Fix `:VimwikiShowVersion` command.
|
||||||
* PR #634: Removed extra newlines that were inserted before/after
|
* PR #634: Removed extra newlines that were inserted before/after
|
||||||
generated links.
|
generated links.
|
||||||
|
Loading…
Reference in New Issue
Block a user