When searching for root line num, stop at the end of the file. (#1015)

* When searching for root line num, stop at the end of the file.

When using the following NERDTreeStatusLine, Vim would lock up and not
work anymore. The problem was that when trying to find the root line
number, the loop was continuing past the end of the file, looping
"forever". The fix was to simply stop at the end of the file.

let g:NERDTreeStatusline = "%{exists('g:NERDTreeFileNode')&&" .
      \ "has_key(g:NERDTreeFileNode.GetSelected(),'path')?" .
      \ "g:NERDTreeFileNode.GetSelected().path.getLastPathComponent(0):''}"

* Update change log.
This commit is contained in:
Phil Runninger 2019-07-04 00:21:50 -04:00 committed by GitHub
parent 62b78de367
commit 89a1a4355b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 1 deletions

View File

@ -1,6 +1,7 @@
# Change Log
#### 5.2...
- **.4**: When searching for root line num, stop at end of file. (PhilRunninger) #1015
- **.3**: Fix `<CR>` key map on the bookmark (lkebin) #1014
- **.2**: Make Enter work on the `.. ( up a dir )` line (PhilRunninger) #1013
- **.1**: Fix nerdtree#version() on Windows. (PhilRunninger) N/A

View File

@ -254,7 +254,7 @@ endfunction
" gets the line number of the root node
function! s:UI.getRootLineNum()
let rootLine = 1
while getline(rootLine) !~# '^\(/\|<\)'
while rootLine <= line('$') && getline(rootLine) !~# '^\(/\|<\)'
let rootLine = rootLine + 1
endwhile
return rootLine