From eff4750831cafa3d4e665b2bce9e53a544d456dc Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Sun, 29 Sep 2019 11:04:38 -0400 Subject: [PATCH 1/3] If file path doesn't exist, :NERDTreeFind its parent directory instead. This happens in the following scenario: ``` :edit path/new_file :NERDTreeFind ``` Instead of an error message about an **invalid path**, this change will now find the parent directory instead. It will not work if the new file is **path/new_folder/new_file**, and that's OK because even vim itself cannot handle both the new folder and the new file; `:w` won't create the new folder. --- autoload/nerdtree/ui_glue.vim | 3 +++ 1 file changed, 3 insertions(+) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index b82e7918..4ba5b05f 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -284,6 +284,9 @@ endfunction " FUNCTION: s:findAndRevealPath(pathStr) {{{1 function! s:findAndRevealPath(pathStr) let l:pathStr = !empty(a:pathStr) ? a:pathStr : expand('%:p') + if !filereadable(l:pathStr) + let l:pathStr = fnamemodify(l:pathStr, ':h') + endif if empty(l:pathStr) call nerdtree#echoWarning('no file for the current buffer') From 1c0a88212f3e563db9204fbb232abf57661040dd Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Sun, 29 Sep 2019 11:26:33 -0400 Subject: [PATCH 2/3] Update version number in change log. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dbcdfc83..76266f12 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Change Log #### 6.0... +- **.2**: If file path doesn't exist, :NERDTreeFind its parent directory instead. (PhilRunninger) [#1043](https://github.com/scrooloose/nerdtree/pull/1043) - **.1**: Reintroduce necessary variable mistakenly removed. (PhilRunninger) [#1040](https://github.com/scrooloose/nerdtree/pull/1040) - **.0**: Make the behavior of window splits consistent (dragonxlwang, PhilRunninger) [#1035](https://github.com/scrooloose/nerdtree/pull/1035) #### 5.3... From 6dc658f8a687dbee6c5417a01d39d4e0d8459999 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Sun, 29 Sep 2019 11:27:45 -0400 Subject: [PATCH 3/3] Change version change from PATCH to MINOR. --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 76266f12..bcb99c6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,8 @@ # Change Log +#### 6.1... +- **.0**: If file path doesn't exist, :NERDTreeFind its parent directory instead. (PhilRunninger) [#1043](https://github.com/scrooloose/nerdtree/pull/1043) #### 6.0... -- **.2**: If file path doesn't exist, :NERDTreeFind its parent directory instead. (PhilRunninger) [#1043](https://github.com/scrooloose/nerdtree/pull/1043) - **.1**: Reintroduce necessary variable mistakenly removed. (PhilRunninger) [#1040](https://github.com/scrooloose/nerdtree/pull/1040) - **.0**: Make the behavior of window splits consistent (dragonxlwang, PhilRunninger) [#1035](https://github.com/scrooloose/nerdtree/pull/1035) #### 5.3...