Merge pull request #1090 from bouk/open-on-find-unsaved-file

Open the parent directory when revealing a non-existent file
This commit is contained in:
Phil Runninger 2020-02-20 09:10:19 -05:00 committed by GitHub
commit e67324fdea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -4,6 +4,8 @@
version in an unordered list. The format is: version in an unordered list. The format is:
- **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR)
--> -->
#### 6.7
- **.0**: Open the parent directory when revealing a non-existent file with :NERDTreeFind (bouk) [#1090](https://github.com/preservim/nerdtree/pull/1090)
#### 6.6 #### 6.6
- **.1**: [add] How to install using dein.vim (kazukazuinaina) [#1087](https://github.com/preservim/nerdtree/pull/1087) - **.1**: [add] How to install using dein.vim (kazukazuinaina) [#1087](https://github.com/preservim/nerdtree/pull/1087)
- **.0**: Add the ability to turn off directory arrows (PhilRunninger) [#1085](https://github.com/preservim/nerdtree/pull/1085) - **.0**: Add the ability to turn off directory arrows (PhilRunninger) [#1085](https://github.com/preservim/nerdtree/pull/1085)

View File

@ -284,6 +284,7 @@ endfunction
" FUNCTION: s:findAndRevealPath(pathStr) {{{1 " FUNCTION: s:findAndRevealPath(pathStr) {{{1
function! s:findAndRevealPath(pathStr) abort function! s:findAndRevealPath(pathStr) abort
let l:pathStr = !empty(a:pathStr) ? a:pathStr : expand('%:p') let l:pathStr = !empty(a:pathStr) ? a:pathStr : expand('%:p')
let l:revealOpts = {}
if empty(l:pathStr) if empty(l:pathStr)
call nerdtree#echoWarning('no file for the current buffer') call nerdtree#echoWarning('no file for the current buffer')
@ -292,6 +293,7 @@ function! s:findAndRevealPath(pathStr) abort
if !filereadable(l:pathStr) if !filereadable(l:pathStr)
let l:pathStr = fnamemodify(l:pathStr, ':h') let l:pathStr = fnamemodify(l:pathStr, ':h')
let l:revealOpts['open'] = 1
endif endif
try try
@ -327,7 +329,7 @@ function! s:findAndRevealPath(pathStr) abort
call b:NERDTree.ui.setShowHidden(1) call b:NERDTree.ui.setShowHidden(1)
endif endif
let l:node = b:NERDTree.root.reveal(l:pathObj) let l:node = b:NERDTree.root.reveal(l:pathObj, l:revealOpts)
call b:NERDTree.render() call b:NERDTree.render()
call l:node.putCursorHere(1, 0) call l:node.putCursorHere(1, 0)
endfunction endfunction