Skip to content

Commit

Permalink
Merge pull request #1090 from bouk/open-on-find-unsaved-file
Browse files Browse the repository at this point in the history
Open the parent directory when revealing a non-existent file
  • Loading branch information
PhilRunninger authored Feb 20, 2020
2 parents 0761255 + 5249b30 commit e67324f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
version in an unordered list. The format is:
- **.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
- **.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)
Expand Down
4 changes: 3 additions & 1 deletion autoload/nerdtree/ui_glue.vim
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ endfunction
" FUNCTION: s:findAndRevealPath(pathStr) {{{1
function! s:findAndRevealPath(pathStr) abort
let l:pathStr = !empty(a:pathStr) ? a:pathStr : expand('%:p')
let l:revealOpts = {}

if empty(l:pathStr)
call nerdtree#echoWarning('no file for the current buffer')
Expand All @@ -292,6 +293,7 @@ function! s:findAndRevealPath(pathStr) abort

if !filereadable(l:pathStr)
let l:pathStr = fnamemodify(l:pathStr, ':h')
let l:revealOpts['open'] = 1
endif

try
Expand Down Expand Up @@ -327,7 +329,7 @@ function! s:findAndRevealPath(pathStr) abort
call b:NERDTree.ui.setShowHidden(1)
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 l:node.putCursorHere(1, 0)
endfunction
Expand Down

0 comments on commit e67324f

Please sign in to comment.