@@ -442,7 +442,7 @@ endfunction
442442
443443function ! 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) ' )
446446endfunction
447447
448448function ! s: compiler_complete (compiler , A, L, P ) abort
@@ -477,12 +477,13 @@ function! s:compiler_complete(compiler, A, L, P) abort
477477endfunction
478478
479479function ! 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