From c758d2a79ae0e4b8602e09834800ed0b3d71d0fe Mon Sep 17 00:00:00 2001 From: Marco Hinz Date: Sat, 6 Apr 2019 16:11:13 +0200 Subject: [PATCH] Changing to dir and VCS root is not mutually exclusive If these two options are set.. g:startify_change_to_vcs_root (0 by default) g:startify_change_to_dir (1 by default) ..try changing to the VCS root first and, if that fails, to the directory of the current file afterwards. Fixes https://github.com/mhinz/vim-startify/issues/364 --- autoload/startify.vim | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/autoload/startify.vim b/autoload/startify.vim index 5b9ab81..3b122e5 100644 --- a/autoload/startify.vim +++ b/autoload/startify.vim @@ -874,9 +874,14 @@ function! s:check_user_options(path) abort execute 'silent bwipeout' a:path call startify#session_delete_buffers() execute 'source' session - elseif get(g:, 'startify_change_to_vcs_root') - call s:cd_to_vcs_root(a:path) - elseif get(g:, 'startify_change_to_dir', 1) + return + endif + + if get(g:, 'startify_change_to_vcs_root') && s:cd_to_vcs_root(a:path) + return + endif + + if get(g:, 'startify_change_to_dir', 1) if isdirectory(a:path) execute 'lcd' a:path else @@ -897,9 +902,10 @@ function! s:cd_to_vcs_root(path) abort let root = finddir(vcs, dir .';') if !empty(root) execute 'cd '. fnameescape(fnamemodify(root, ':h')) - return + return 1 endif endfor + return 0 endfunction " Function: s:close {{{1