mirror of
https://github.com/preservim/nerdtree.git
synced 2025-11-08 11:23:48 -05:00
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:
@@ -1,6 +1,7 @@
|
||||
# Change Log
|
||||
|
||||
#### 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)
|
||||
#### 6.0...
|
||||
- **.1**: Reintroduce necessary variable mistakenly removed. (PhilRunninger) [#1040](https://github.com/scrooloose/nerdtree/pull/1040)
|
||||
|
||||
@@ -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
|
||||
" number is shown.
|
||||
function! nerdtree#version(...)
|
||||
let l:changelog = readfile(join([s:rootNERDTreePath, "CHANGELOG.md"], nerdtree#slash()))
|
||||
let l:text = 'Unknown'
|
||||
let l:line = 0
|
||||
while l:line <= len(l:changelog)
|
||||
if l:changelog[l:line] =~ '\d\+\.\d\+'
|
||||
let l:text = substitute(l:changelog[l:line], '.*\(\d\+.\d\+\).*', '\1', '')
|
||||
let l:text .= substitute(l:changelog[l:line+1], '^.\{-}\(\.\d\+\).\{-}:\(.*\)', a:0>0 ? '\1:\2' : '\1', '')
|
||||
break
|
||||
endif
|
||||
let l:line += 1
|
||||
endwhile
|
||||
try
|
||||
let l:changelog = readfile(join([s:rootNERDTreePath, "CHANGELOG.md"], nerdtree#slash()))
|
||||
let l:line = 0
|
||||
while l:line <= len(l:changelog)
|
||||
if l:changelog[l:line] =~ '\d\+\.\d\+'
|
||||
let l:text = substitute(l:changelog[l:line], '.*\(\d\+.\d\+\).*', '\1', '')
|
||||
let l:text .= substitute(l:changelog[l:line+1], '^.\{-}\(\.\d\+\).\{-}:\(.*\)', a:0>0 ? '\1:\2' : '\1', '')
|
||||
break
|
||||
endif
|
||||
let l:line += 1
|
||||
endwhile
|
||||
catch
|
||||
endtry
|
||||
return l:text
|
||||
endfunction
|
||||
|
||||
|
||||
Reference in New Issue
Block a user