Skip to content

Conversation

@bravestarr
Copy link
Contributor

@bravestarr bravestarr commented Apr 26, 2018

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.

Copy link
Member

@PhilRunninger PhilRunninger left a 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.

if strdisplaywidth(pathStr) > pathStrMaxLen
while strdisplaywidth(pathStr) > pathStrMaxLen && strchars(pathStr) > 0
let pathStr = strcharpart(pathStr, 1)
let pathStr = substitute(pathStr, '.\{1}', '', '')
Copy link
Member

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.

if strdisplaywidth(toReturn) > limit-1
while strdisplaywidth(toReturn) > limit-1 && strchars(toReturn) > 0
let toReturn = strcharpart(toReturn, 1)
let toReturn = substitute(toReturn, '.\{1}', '', '')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same regex comment here.

@bravestarr bravestarr closed this Apr 26, 2018
@bravestarr bravestarr deleted the fix-multibyte-path branch April 26, 2018 13:14
@bravestarr bravestarr restored the fix-multibyte-path branch April 26, 2018 13:17
@bravestarr bravestarr reopened this Apr 26, 2018
@bravestarr
Copy link
Contributor Author

bravestarr commented Apr 26, 2018

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 if exists("*strcharpart"). Now I have resolved the conflicts and adopted the regex you advised.

@PhilRunninger PhilRunninger merged commit 925a96f into preservim:master Apr 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants