Merge pull request #833 from hav4ik/master

Fixed error 'unknown function strcharpart' for older versions of Vim
This commit is contained in:
Phil Runninger 2018-04-25 01:25:43 -04:00 committed by GitHub
commit cc60495fe0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 7 deletions

View File

@ -287,10 +287,14 @@ function! s:Bookmark.str()
let pathStr = self.path.str({'format': 'UI'}) let pathStr = self.path.str({'format': 'UI'})
if strdisplaywidth(pathStr) > pathStrMaxLen if strdisplaywidth(pathStr) > pathStrMaxLen
while strdisplaywidth(pathStr) > pathStrMaxLen && strchars(pathStr) > 0 if exists("*strcharpart")
let pathStr = strcharpart(pathStr, 1) while strdisplaywidth(pathStr) > pathStrMaxLen && strchars(pathStr) > 0
endwhile let pathStr = strcharpart(pathStr, 1)
let pathStr = '<' . pathStr endwhile
let pathStr = '<' . pathStr
else
let pathStr = '<' . strpart(pathStr, len(pathStr) - pathStrMaxLen)
endif
endif endif
return '>' . self.name . ' ' . pathStr return '>' . self.name . ' ' . pathStr
endfunction endfunction

View File

@ -720,9 +720,13 @@ function! s:Path.str(...)
if has_key(options, 'truncateTo') if has_key(options, 'truncateTo')
let limit = options['truncateTo'] let limit = options['truncateTo']
if strdisplaywidth(toReturn) > limit-1 if strdisplaywidth(toReturn) > limit-1
while strdisplaywidth(toReturn) > limit-1 && strchars(toReturn) > 0 if exists("*strcharpart")
let toReturn = strcharpart(toReturn, 1) while strdisplaywidth(toReturn) > limit-1 && strchars(toReturn) > 0
endwhile let toReturn = strcharpart(toReturn, 1)
endwhile
else
let toReturn = toReturn[(len(toReturn)-limit+1):]
endif
if len(split(toReturn, '/')) > 1 if len(split(toReturn, '/')) > 1
let toReturn = '</' . join(split(toReturn, '/')[1:], '/') . '/' let toReturn = '</' . join(split(toReturn, '/')[1:], '/') . '/'
else else