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,17 +10,20 @@ 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'
let l:line = 0 try
while l:line <= len(l:changelog) let l:changelog = readfile(join([s:rootNERDTreePath, "CHANGELOG.md"], nerdtree#slash()))
if l:changelog[l:line] =~ '\d\+\.\d\+' let l:line = 0
let l:text = substitute(l:changelog[l:line], '.*\(\d\+.\d\+\).*', '\1', '') while l:line <= len(l:changelog)
let l:text .= substitute(l:changelog[l:line+1], '^.\{-}\(\.\d\+\).\{-}:\(.*\)', a:0>0 ? '\1:\2' : '\1', '') if l:changelog[l:line] =~ '\d\+\.\d\+'
break let l:text = substitute(l:changelog[l:line], '.*\(\d\+.\d\+\).*', '\1', '')
endif let l:text .= substitute(l:changelog[l:line+1], '^.\{-}\(\.\d\+\).\{-}:\(.*\)', a:0>0 ? '\1:\2' : '\1', '')
let l:line += 1 break
endwhile endif
let l:line += 1
endwhile
catch
endtry
return l:text return l:text
endfunction endfunction