mirror of
https://github.com/preservim/nerdtree.git
synced 2024-11-22 15:18:23 +08:00
Open the parent directory when revealing a non-existent file
Right now it just reveals the directory but leaves it closed. Related to #1043
This commit is contained in:
parent
07612557eb
commit
6224d20698
|
@ -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')
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user