1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-24 02:40:05 +08:00

[issue#2367]: clear rootDir cache after rooter pattern changed (#2370)

> SpaceVim will try to find root before loadding custom config,
  > so that is why It can not find your project root. yes, if the
  > project rooter patterns is change the cache should be cleared.

  The fix here is create a shadow copy of
  `g:spacevim_project_rooter_pattern` and if user changed it should
  be different from the shadow version, we clear the cache and sync
  them again.
This commit is contained in:
Dyno Fu 2018-12-27 07:18:29 -08:00 committed by Wang Shidong
parent 6efba6d3a0
commit 119418756b
2 changed files with 12 additions and 1 deletions

View File

@ -16,6 +16,7 @@
call add(g:spacevim_project_rooter_patterns, '.SpaceVim.d/') call add(g:spacevim_project_rooter_patterns, '.SpaceVim.d/')
let s:spacevim_project_rooter_patterns = copy(g:spacevim_project_rooter_patterns)
let s:project_paths = {} let s:project_paths = {}
@ -79,6 +80,12 @@ function! SpaceVim#plugins#projectmanager#reg_callback(func) abort
endfunction endfunction
function! SpaceVim#plugins#projectmanager#current_root() abort function! SpaceVim#plugins#projectmanager#current_root() abort
" if rooter patterns changed, clear cache.
" https://github.com/SpaceVim/SpaceVim/issues/2367
if join(g:spacevim_project_rooter_patterns, ':') !=# join(s:spacevim_project_rooter_patterns, ':')
call setbufvar('%', 'rootDir', '')
let s:spacevim_project_rooter_patterns = copy(g:spacevim_project_rooter_patterns)
endif
let rootdir = getbufvar('%', 'rootDir', '') let rootdir = getbufvar('%', 'rootDir', '')
if empty(rootdir) if empty(rootdir)
let rootdir = s:find_root_directory() let rootdir = s:find_root_directory()

View File

@ -12,7 +12,11 @@ The next release is v1.0.1
### Fixed ### Fixed
### Doc - Clear rootDir cache after rooter pattern change([#2370](https://github.com/SpaceVim/SpaceVim/pull/2370))
### Removed
### Doc, Wiki && Website
### Others ### Others