Skip to content

Commit 925a96f

Browse files
Merge pull request #834 from bravestarr/fix-multibyte-path
Replace strcharpart() with substitute() for backward compatibility
2 parents cc60495 + abf2003 commit 925a96f

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

lib/nerdtree/bookmark.vim

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -287,14 +287,10 @@ function! s:Bookmark.str()
287287

288288
let pathStr = self.path.str({'format': 'UI'})
289289
if strdisplaywidth(pathStr) > pathStrMaxLen
290-
if exists("*strcharpart")
291-
while strdisplaywidth(pathStr) > pathStrMaxLen && strchars(pathStr) > 0
292-
let pathStr = strcharpart(pathStr, 1)
293-
endwhile
294-
let pathStr = '<' . pathStr
295-
else
296-
let pathStr = '<' . strpart(pathStr, len(pathStr) - pathStrMaxLen)
297-
endif
290+
while strdisplaywidth(pathStr) > pathStrMaxLen && strchars(pathStr) > 0
291+
let pathStr = substitute(pathStr, '^.', '', '')
292+
endwhile
293+
let pathStr = '<' . pathStr
298294
endif
299295
return '>' . self.name . ' ' . pathStr
300296
endfunction

lib/nerdtree/path.vim

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -720,13 +720,9 @@ function! s:Path.str(...)
720720
if has_key(options, 'truncateTo')
721721
let limit = options['truncateTo']
722722
if strdisplaywidth(toReturn) > limit-1
723-
if exists("*strcharpart")
724-
while strdisplaywidth(toReturn) > limit-1 && strchars(toReturn) > 0
725-
let toReturn = strcharpart(toReturn, 1)
726-
endwhile
727-
else
728-
let toReturn = toReturn[(len(toReturn)-limit+1):]
729-
endif
723+
while strdisplaywidth(toReturn) > limit-1 && strchars(toReturn) > 0
724+
let toReturn = substitute(toReturn, '^.', '', '')
725+
endwhile
730726
if len(split(toReturn, '/')) > 1
731727
let toReturn = '</' . join(split(toReturn, '/')[1:], '/') . '/'
732728
else

0 commit comments

Comments
 (0)