mirror of
https://github.com/preservim/nerdtree.git
synced 2025-11-08 11:23:48 -05:00
If file path doesn't exist, :NERDTreeFind its parent directory instead. (#1043)
* 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. * Update version number in change log. * Change version change from PATCH to MINOR.
This commit is contained in:
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user