Fix: VimwikiGoto completion with file with space (#1229)

This commit is contained in:
Tinmarino
2023-06-14 13:02:00 -04:00
parent 69a5682d6f
commit 298a409b74
2 changed files with 40 additions and 5 deletions
+37 -5
View File
@@ -394,9 +394,33 @@ function! vimwiki#base#open_link(cmd, link, ...) abort
endfunction endfunction
function! vimwiki#base#get_globlinks(...) abort function! vimwiki#base#nop1(stg) abort
" Nop with one arg, used if callback is required
return a:stg
endfunction
function! vimwiki#base#get_globlinks_escaped(...) abort
" Proxy: Called by command completion
let args = copy(a:000)
call insert(args, 'fnameescape')
return call('vimwiki#base#get_globlinks_callback', args)
endfunction
function! vimwiki#base#get_globlinks_raw(...) abort
" Proxy: Called by command completion
let args = copy(a:000)
call insert(args, 'vimwiki#base#nop1')
return call('vimwiki#base#get_globlinks_callback', args)
endfunction
function! vimwiki#base#get_globlinks_callback(callback, ...) abort
" Escape global link " Escape global link
" Called by command completion " Called by command completion
" [1] callback <string> of a function converting file <string> => escaped file <string>
" -- ex: fnameescape
let s_arg_lead = a:0 > 0 ? a:1 : '' let s_arg_lead = a:0 > 0 ? a:1 : ''
" only get links from the current dir " only get links from the current dir
" change to the directory of the current file " change to the directory of the current file
@@ -414,6 +438,8 @@ function! vimwiki#base#get_globlinks(...) abort
" " use smart case matching " " use smart case matching
let r_arg = substitute(s_arg_lead, '\u', '[\0\l\0]', 'g') let r_arg = substitute(s_arg_lead, '\u', '[\0\l\0]', 'g')
call filter(lst, '-1 != match(v:val, r_arg)') call filter(lst, '-1 != match(v:val, r_arg)')
" Apply callback to each item
call map(lst, a:callback . '(v:val)')
" Return list (for customlist completion) " Return list (for customlist completion)
return lst return lst
endfunction endfunction
@@ -491,7 +517,7 @@ function! vimwiki#base#goto(...) abort
" Jump: to other wikifile, specified on command mode " Jump: to other wikifile, specified on command mode
" Called: by command VimwikiGoto (Exported) " Called: by command VimwikiGoto (Exported)
let key = a:0 > 0 && a:1 !=# '' ? a:1 : input('Enter name: ', '', let key = a:0 > 0 && a:1 !=# '' ? a:1 : input('Enter name: ', '',
\ 'customlist,vimwiki#base#complete_links') \ 'customlist,vimwiki#base#complete_links_raw')
if key ==# '' if key ==# ''
" Input cancelled " Input cancelled
@@ -2865,9 +2891,15 @@ function! vimwiki#base#detect_nested_syntax() abort
endfunction endfunction
function! vimwiki#base#complete_links(ArgLead, CmdLine, CursorPos) abort function! vimwiki#base#complete_links_escaped(ArgLead, CmdLine, CursorPos) abort
" Complete escaping globlinks " Complete globlinks escaping
return vimwiki#base#get_globlinks(a:ArgLead) return vimwiki#base#get_globlinks_escaped(a:ArgLead)
endfunction
function! vimwiki#base#complete_links_raw(ArgLead, CmdLine, CursorPos) abort
" Complete globlinks as raw string (unescaped)
return vimwiki#base#get_globlinks_raw(a:ArgLead)
endfunction endfunction
+3
View File
@@ -4023,6 +4023,9 @@ This is somewhat experimental, and will probably be refined over time.
2023.04.04~ 2023.04.04~
Fixed:~ Fixed:~
* Issue #1229: VimwikiGoto completion with file with space
Must complete file unescaped as argument is then quoted
* PR #1324: Fix pressing escape in VimwikiGoto prompt (rddunphy)
* Issue #1336: vimwiki#diary#calendar_sign throws an error * Issue #1336: vimwiki#diary#calendar_sign throws an error
when g:vimwiki_list is not set when g:vimwiki_list is not set