From d6bda025f1bfd1ca9b06f2dfb3772982dff1fa17 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Sun, 29 Jan 2017 18:23:05 +0900 Subject: [PATCH] Fix Vim 8 installer on Windows when path contains spaces Close #565 --- plug.vim | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/plug.vim b/plug.vim index 95d8eab..5437fe1 100644 --- a/plug.vim +++ b/plug.vim @@ -1143,6 +1143,9 @@ endfunction function! s:job_exit_cb(self, data) abort let a:self.running = 0 let a:self.error = a:data != 0 + if has_key(a:self, 'tempname') + call delete(a:self.tempname) + endif call s:reap(a:self.name) call s:tick() endfunction @@ -1164,8 +1167,8 @@ function! s:spawn(name, cmd, opts) let job = { 'name': a:name, 'running': 1, 'error': 0, 'lines': [''], \ 'new': get(a:opts, 'new', 0) } let s:jobs[a:name] = job - let argv = add(s:is_win ? ['cmd', '/c'] : ['sh', '-c'], - \ has_key(a:opts, 'dir') ? s:with_cd(a:cmd, a:opts.dir) : a:cmd) + let cmd = has_key(a:opts, 'dir') ? s:with_cd(a:cmd, a:opts.dir) : a:cmd + let argv = s:is_win ? cmd : ['sh', '-c', cmd] if s:nvim call extend(job, { @@ -1182,6 +1185,11 @@ function! s:spawn(name, cmd, opts) \ 'Invalid arguments (or job table is full)'] endif elseif s:vim8 + if s:is_win + let job.tempname = tempname().'.bat' + call writefile([argv], job.tempname) + let argv = job.tempname + endif let jid = job_start(argv, { \ 'out_cb': function('s:job_cb', ['s:job_out_cb', job]), \ 'exit_cb': function('s:job_cb', ['s:job_exit_cb', job]),