From 3c3a835d8dab411c20b9214f215a4a10c7a04fc0 Mon Sep 17 00:00:00 2001 From: Marco Hinz Date: Wed, 1 Jun 2016 02:11:33 +0200 Subject: [PATCH] Check user options properly References #220. --- autoload/startify.vim | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/autoload/startify.vim b/autoload/startify.vim index 8275476..38a2369 100644 --- a/autoload/startify.vim +++ b/autoload/startify.vim @@ -420,17 +420,17 @@ function! s:open_buffer(entry) if a:entry.type == 'special' execute a:entry.cmd elseif a:entry.type == 'session' - execute a:entry.cmd a:entry.path + execute a:entry.cmd fnameescape(a:entry.path) elseif a:entry.type == 'file' if line2byte('$') == -1 - execute 'edit' a:entry.path + execute 'edit' fnameescape(a:entry.path) else if a:entry.cmd == 'tabnew' wincmd = endif - execute a:entry.cmd a:entry.path + execute a:entry.cmd fnameescape(a:entry.path) endif - call s:check_user_options() + call s:check_user_options(a:entry.path) endif endfunction @@ -757,22 +757,15 @@ function! s:sort_by_tick(one, two) endfunction " Function: s:check_user_options {{{1 -function! s:check_user_options() abort - let path = expand('%') - let session = path . s:sep .'Session.vim' +function! s:check_user_options(path) abort + let session = a:path . s:sep .'Session.vim' - " change to VCS root directory if get(g:, 'startify_session_autoload') && filereadable(session) execute 'source' session elseif get(g:, 'startify_change_to_vcs_root') - call s:cd_to_vcs_root(path) - " change directory + call s:cd_to_vcs_root(a:path) elseif get(g:, 'startify_change_to_dir', 1) - if isdirectory(path) - lcd % - else - lcd %:p:h - endif + execute 'lcd' fnameescape(isdirectory(a:path) ? a:path : fnamemodify(a:path, ':h')) endif endfunction @@ -782,7 +775,7 @@ function! s:cd_to_vcs_root(path) abort for vcs in [ '.git', '.hg', '.bzr', '.svn' ] let root = finddir(vcs, dir .';') if !empty(root) - execute 'cd '. fnamemodify(root, ':h') + execute 'cd '. fnameescape(fnamemodify(root, ':h')) return endif endfor