mirror of
https://github.com/preservim/nerdtree.git
synced 2024-12-01 22:53:35 +08:00
Have "finAndRevealPath()" fail on no file
If a file does not exist for the current buffer, this function should fail with a clear warning message. Here, I improved the messages that this function prints so that it fails gracefully when no path can be determined in the calling context.
This commit is contained in:
parent
344119439e
commit
01b011d38e
|
@ -261,18 +261,19 @@ function! s:displayHelp()
|
||||||
call b:NERDTree.ui.centerView()
|
call b:NERDTree.ui.centerView()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: s:findAndRevealPath(path) {{{1
|
" FUNCTION: s:findAndRevealPath(pathStr) {{{1
|
||||||
function! s:findAndRevealPath(path)
|
function! s:findAndRevealPath(pathStr)
|
||||||
let l:path = a:path
|
let l:pathStr = !empty(a:pathStr) ? a:pathStr : expand('%:p')
|
||||||
|
|
||||||
if empty(l:path)
|
if empty(l:pathStr)
|
||||||
let l:path = expand('%:p')
|
call nerdtree#echoWarning('no file for the current buffer')
|
||||||
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
try
|
try
|
||||||
let l:pathObj = g:NERDTreePath.New(l:path)
|
let l:pathObj = g:NERDTreePath.New(l:pathStr)
|
||||||
catch /^NERDTree.InvalidArgumentsError/
|
catch /^NERDTree.InvalidArgumentsError/
|
||||||
call nerdtree#echo('no file for the current buffer')
|
call nerdtree#echoWarning('invalid path')
|
||||||
return
|
return
|
||||||
endtry
|
endtry
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user