-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace strcharpart() with substitute() for backward compatibility #834
Replace strcharpart() with substitute() for backward compatibility #834
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolve the conflicts, and I'll merge this. We don't need the if exists("*strcharpart")
block introduced in #833 anymore, but your changes here don't account for its removal.
lib/nerdtree/bookmark.vim
Outdated
@@ -288,7 +288,7 @@ function! s:Bookmark.str() | |||
let pathStr = self.path.str({'format': 'UI'}) | |||
if strdisplaywidth(pathStr) > pathStrMaxLen | |||
while strdisplaywidth(pathStr) > pathStrMaxLen && strchars(pathStr) > 0 | |||
let pathStr = strcharpart(pathStr, 1) | |||
let pathStr = substitute(pathStr, '.\{1}', '', '') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the regex '^.'
would be safer to use here. That guarantees it finds the first character.
lib/nerdtree/path.vim
Outdated
@@ -721,7 +721,7 @@ function! s:Path.str(...) | |||
let limit = options['truncateTo'] | |||
if strdisplaywidth(toReturn) > limit-1 | |||
while strdisplaywidth(toReturn) > limit-1 && strchars(toReturn) > 0 | |||
let toReturn = strcharpart(toReturn, 1) | |||
let toReturn = substitute(toReturn, '.\{1}', '', '') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same regex comment here.
I have commit this change to the branch used in #830, but the branch didn't sync to the master branch, so I did't mention the removal of |
Pull request #833 has supplied a fix to workaround the backward compatibility problem in #830. But the multi-byte path problem will appear again in the older version of vim before the function strcharpart was introduced. We can use substitute to achieve the same result as when strcharpart is used.