From 18071f599955f6720170d9daa6835a663a6bbaf0 Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Wed, 22 Aug 2018 17:01:08 -0400 Subject: [PATCH] NERDTreeCWD: reset CWD if changed by NERDTreeFocus When the user has `'autochdir'` turned on, opening a new NERDTree will cause the current working directory to change. To prevent this happening, remember the CWD and reset it if NERDTreeFocus caused it to change. --- plugin/NERD_tree.vim | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 71d719a..f8700d5 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -202,7 +202,11 @@ function! NERDTreeFocus() endfunction function! NERDTreeCWD() + let l:cwd = getcwd() call NERDTreeFocus() + if l:cwd != getcwd() + exec 'cd '.l:cwd + endif call nerdtree#ui_glue#chRootCwd() endfunction