1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 12:50:04 +08:00

Merge pull request #1288 from SpaceVim/project_manager

Fix project manager
This commit is contained in:
Wang Shidong 2018-01-17 22:05:06 +08:00 committed by GitHub
commit b1b8a354c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -122,7 +122,7 @@ function! s:find_root_directory() abort
else
let dir = SpaceVim#util#findFileInParent(pattern, fd)
endif
if !empty(dir)
if !empty(dir) && isdirectory(dir)
let dir = fnamemodify(dir, ':p')
call SpaceVim#logger#info("Find project root('" . pattern . "','" . fd . "'):" . dir)
call add(dirs, dir)
@ -133,12 +133,11 @@ endfunction
function! s:sort_dirs(dirs) abort
let dirs = sort(a:dirs, funcref('s:compare'))
let dir = get(sort(a:dirs, funcref('s:compare')), 0, '')
let bufdir = getbufvar('%', 'rootDir', '')
if bufdir ==# get(dirs, 0, '')
if bufdir ==# dir
return ''
else
let dir = dirs[0]
if isdirectory(dir)
let dir = fnamemodify(dir, ':p:h:h')
else
@ -155,7 +154,7 @@ function! s:compare(d1, d2) abort
endfunction
function! s:change_to_root_directory() abort
if s:find_root_directory()
if !empty(s:find_root_directory())
call SpaceVim#plugins#projectmanager#RootchandgeCallback()
endif
return getbufvar('%', 'rootDir', '')