fix: allow multibyte characters on buffer picker #123
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hey, thanks for such a cool plugin. In the past I struggled with tabline plugins and setting the paddings and names like I wanted, and this plugin just let us do everything we want it, I really appreciate it 🙏
But I have found that the buffer_picker would not work very well when the filename starts with a mulibyte character, when we're using the filename to decide the picker character, or if we set multibyte characters in the
letters
option in the setup. And by multibyte character I mean things likeç
,ã
,é
etc.My keyboard layout has special characters, so I wanted to use them in the "letters" option, but then it would show some weird characters, like this:
Here my first letter should be
ç
, but it is shown as this weird<c3>
thing on first buffer and<a7>
on the second, which are the first and second byte of the multibyte characterç
. And even if I do pressç
, it takes me nowhere. I suspected this would be caused by lua not treating strings the way I'd usually expect. I very recently had an issue setting cokeline up, as you can see in this reddit post: https://www.reddit.com/r/neovim/comments/14kdw8v/how_to_get_the_first_character_of_a_string_when/So I peeked the code really quick and found some
string.sub
usage, which is exactly what breaks it. I changed it for somevim.fn.strcharpart
, which takes an index (0 based) and a length and gets the substring, but this index is considering characters, and not bytes, unlike lua'sstring.sub
function.Maybe I should have opened an issue, but since I got what apparently could be the fix, I opened a pull request directly. Sorry if that was not cool! ):
Anyways, what is your opinion on this?