From 1353fa47ee3a81083c284e28ff4f7d92655d7c9e Mon Sep 17 00:00:00 2001 From: Andy Stewart Date: Thu, 14 Sep 2023 13:34:59 +0100 Subject: [PATCH] Extract s:clear_cache() --- plugin/rooter.vim | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugin/rooter.vim b/plugin/rooter.vim index 10d9ba2..bdb223c 100644 --- a/plugin/rooter.vim +++ b/plugin/rooter.vim @@ -65,7 +65,7 @@ command! -bar RooterToggle call toggle() augroup rooter autocmd! autocmd VimEnter,BufReadPost,BufEnter * nested if !g:rooter_manual_only | call rooter(+expand('')) | endif - autocmd BufWritePost * nested if !g:rooter_manual_only | call setbufvar(+expand(''), 'rootDir', '') | call rooter(+expand('')) | endif + autocmd BufWritePost * nested if !g:rooter_manual_only | call clear_cache(+expand('')) | call rooter(+expand('')) | endif augroup END @@ -89,6 +89,11 @@ function! s:rooter(...) endfunction +function! s:clear_cache(bufnr) + call setbufvar(a:bufnr, 'rootDir', '') +endfunction + + " Returns true if we should change to the buffer's root directory, false otherwise. function! s:activate() if index(g:rooter_buftypes, &buftype) == -1 | return 0 | endif