Catch errors when trying to read CHANGELOG.md. (#1045)

* Catch errors when trying to read CHANGELOG.md.

The ArchLinux package
(https://www.archlinux.org/packages/community/any/vim-nerdtree/) puts
this file in the wrong location.

* Update version number in change log.
This commit is contained in:
Phil Runninger
2019-10-01 09:17:32 -04:00
committed by GitHub
parent 6318406f66
commit 2d639b70e7
2 changed files with 14 additions and 10 deletions

View File

@@ -1,6 +1,7 @@
# Change Log # Change Log
#### 6.1... #### 6.1...
- **.1**: Catch errors when trying to read CHANGELOG.md. (PhilRunninger) [#1045](https://github.com/scrooloose/nerdtree/pull/1045)
- **.0**: If file path doesn't exist, :NERDTreeFind its parent directory instead. (PhilRunninger) [#1043](https://github.com/scrooloose/nerdtree/pull/1043) - **.0**: If file path doesn't exist, :NERDTreeFind its parent directory instead. (PhilRunninger) [#1043](https://github.com/scrooloose/nerdtree/pull/1043)
#### 6.0... #### 6.0...
- **.1**: Reintroduce necessary variable mistakenly removed. (PhilRunninger) [#1040](https://github.com/scrooloose/nerdtree/pull/1040) - **.1**: Reintroduce necessary variable mistakenly removed. (PhilRunninger) [#1040](https://github.com/scrooloose/nerdtree/pull/1040)

View File

@@ -10,8 +10,9 @@ let s:rootNERDTreePath = resolve(expand("<sfile>:p:h:h"))
" change log is shown for the current version; otherwise, only the version " change log is shown for the current version; otherwise, only the version
" number is shown. " number is shown.
function! nerdtree#version(...) function! nerdtree#version(...)
let l:changelog = readfile(join([s:rootNERDTreePath, "CHANGELOG.md"], nerdtree#slash()))
let l:text = 'Unknown' let l:text = 'Unknown'
try
let l:changelog = readfile(join([s:rootNERDTreePath, "CHANGELOG.md"], nerdtree#slash()))
let l:line = 0 let l:line = 0
while l:line <= len(l:changelog) while l:line <= len(l:changelog)
if l:changelog[l:line] =~ '\d\+\.\d\+' if l:changelog[l:line] =~ '\d\+\.\d\+'
@@ -21,6 +22,8 @@ function! nerdtree#version(...)
endif endif
let l:line += 1 let l:line += 1
endwhile endwhile
catch
endtry
return l:text return l:text
endfunction endfunction