nerdtree

A tree explorer plugin for vim.
Index Commits Files Refs
commit 925a96f58d75b61e39828ea3a802aeef58b7d590
parent cc60495fe06cd064bd8b613d37ad65386bd39a7a
Author: Phil Runninger <PhilRunninger@users.noreply.github.com>
Date:   Thu, 26 Apr 2018 09:36:24 -0400

Merge pull request #834 from bravestarr/fix-multibyte-path

Replace strcharpart() with substitute() for backward compatibility
Diffstat:
Mlib/nerdtree/bookmark.vim | 12++++--------
Mlib/nerdtree/path.vim | 10+++-------
2 files changed, 7 insertions(+), 15 deletions(-)
diff --git a/lib/nerdtree/bookmark.vim b/lib/nerdtree/bookmark.vim
@@ -287,14 +287,10 @@ function! s:Bookmark.str()
 
     let pathStr = self.path.str({'format': 'UI'})
     if strdisplaywidth(pathStr) > pathStrMaxLen
-        if exists("*strcharpart")
-            while strdisplaywidth(pathStr) > pathStrMaxLen && strchars(pathStr) > 0
-                let pathStr = strcharpart(pathStr, 1)
-            endwhile
-            let pathStr = '<' . pathStr
-        else
-            let pathStr = '<' . strpart(pathStr, len(pathStr) - pathStrMaxLen)
-        endif
+        while strdisplaywidth(pathStr) > pathStrMaxLen && strchars(pathStr) > 0
+            let pathStr = substitute(pathStr, '^.', '', '')
+        endwhile
+        let pathStr = '<' . pathStr
     endif
     return '>' . self.name . ' ' . pathStr
 endfunction
diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim
@@ -720,13 +720,9 @@ function! s:Path.str(...)
     if has_key(options, 'truncateTo')
         let limit = options['truncateTo']
         if strdisplaywidth(toReturn) > limit-1
-            if exists("*strcharpart")
-                while strdisplaywidth(toReturn) > limit-1 && strchars(toReturn) > 0
-                    let toReturn = strcharpart(toReturn, 1)
-                endwhile
-            else
-                let toReturn = toReturn[(len(toReturn)-limit+1):]
-            endif
+            while strdisplaywidth(toReturn) > limit-1 && strchars(toReturn) > 0
+                let toReturn = substitute(toReturn, '^.', '', '')
+            endwhile
             if len(split(toReturn, '/')) > 1
                 let toReturn = '</' . join(split(toReturn, '/')[1:], '/') . '/'
             else