Fix #154 - issues with paths containing spaces

This commit is contained in:
Junegunn Choi 2015-02-12 11:35:05 +09:00
parent 7aeff0ef0d
commit ef784c17b1
2 changed files with 12 additions and 10 deletions

View File

@ -115,7 +115,7 @@ function! s:define_commands()
command! -nargs=* -bar -bang -complete=customlist,s:names PlugInstall call s:install('<bang>' == '!', [<f-args>])
command! -nargs=* -bar -bang -complete=customlist,s:names PlugUpdate call s:update('<bang>' == '!', [<f-args>])
command! -nargs=0 -bar -bang PlugClean call s:clean('<bang>' == '!')
command! -nargs=0 -bar PlugUpgrade if s:upgrade() | execute 'source' s:me | endif
command! -nargs=0 -bar PlugUpgrade if s:upgrade() | execute 'source' s:esc(s:me) | endif
command! -nargs=0 -bar PlugStatus call s:status()
command! -nargs=0 -bar PlugDiff call s:diff()
command! -nargs=? -bar PlugSnapshot call s:snapshot(<f-args>)
@ -132,7 +132,7 @@ endfunction
function! s:source(from, ...)
for pattern in a:000
for vim in s:lines(globpath(a:from, pattern))
execute 'source' vim
execute 'source' s:esc(vim)
endfor
endfor
endfunction
@ -1562,11 +1562,12 @@ function! s:snapshot(...) abort
endfor
if a:0 > 0
let fn = s:esc(expand(a:1))
let fn = expand(a:1)
let fne = s:esc(fn)
call writefile(getline(1, '$'), fn)
if !s:is_win | call s:system('chmod +x ' . fn) | endif
if !s:is_win | call s:system('chmod +x ' . fne) | endif
echo 'Saved to '.a:1
silent execute 'e' fn
silent execute 'e' fne
endif
endfunction

View File

@ -1008,21 +1008,22 @@ Execute (PlugClean should not try to remove unmanaged plugins inside g:plug_home
q
**********************************************************************
Execute (PlugSnapshot):
call plug#begin('$TMPDIR/plugged')
Plug 'junegunn/vim-emoji'
Execute (PlugSnapshot / #154 issues with paths containing spaces):
call plug#begin('$TMPDIR/plug with spaces')
Plug 'junegunn/vim-easy-align'
Plug 'junegunn/seoul256.vim'
call plug#end()
PlugClean!
PlugInstall
call plug#load('vim-easy-align') " Should properly hand paths with spaces
PlugSnapshot
AssertEqual '#!/bin/sh', getline(1)
AssertEqual '# Generated by vim-plug', getline(2)
AssertEqual 'vim +PlugUpdate +qa', getline(5)
AssertEqual 'PLUG_HOME=$TMPDIR/plugged', getline(7)
AssertEqual 'PLUG_HOME=$TMPDIR/plug\ with\ spaces', getline(7)
AssertEqual 0, stridx(getline(9), 'cd $PLUG_HOME/seoul256.vim/ && git reset --hard')
AssertEqual 0, stridx(getline(10), 'cd $PLUG_HOME/vim-emoji/ && git reset --hard')
AssertEqual 0, stridx(getline(10), 'cd $PLUG_HOME/vim-easy-align/ && git reset --hard')
AssertEqual 'sh', &filetype
execute 'PlugSnapshot' g:plug_home.'/snapshot.sh'