Skip to content

Commit d6927ff

Browse files
committed
Completion fixes
Closes #202
1 parent 2013b5a commit d6927ff

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

autoload/dispatch.vim

+5-4
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ endfunction
442442

443443
function! s:file_complete(A) abort
444444
return map(split(glob(substitute(a:A, '.\@<=\ze[\\/]\|$', '*', 'g')), "\n"),
445-
\ 'isdirectory(v:val) ? v:val . dispatch#slash() : v:val')
445+
\ 'fnameescape(isdirectory(v:val) ? v:val . dispatch#slash() : v:val)')
446446
endfunction
447447

448448
function! s:compiler_complete(compiler, A, L, P) abort
@@ -477,12 +477,13 @@ function! s:compiler_complete(compiler, A, L, P) abort
477477
endfunction
478478

479479
function! dispatch#command_complete(A, L, P) abort
480-
let args = matchstr(a:L, '\s\zs.*')
480+
let L = strpart(a:L, 0, a:P)
481+
let args = matchstr(L, '\s\zs.*')
481482
let [cmd, opts] = s:extract_opts(args)
482-
let P = a:P + len(cmd) - len(a:L)
483+
let P = a:P + len(cmd) - len(L)
483484
let len = matchend(cmd, '\S\+\s')
484485
if len >= 0 && P >= 0
485-
let args = matchstr(a:L, '\s\zs.*')
486+
let args = matchstr(L, '\s\zs.*')
486487
let compiler = get(opts, 'compiler', dispatch#compiler_for_program(cmd))
487488
let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd' : 'cd'
488489
try

0 commit comments

Comments
 (0)