Skip to content
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

fix: allow multibyte characters on buffer picker #123

Merged

Conversation

lucassperez
Copy link
Contributor

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:

image

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 some vim.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's string.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?

@willothy
Copy link
Owner

Thanks! Definitely agree with this change.

@willothy willothy force-pushed the fix-multibyte-char-buffer-picker branch from f34a686 to 77554eb Compare June 29, 2023 09:09
@willothy willothy merged commit 4698004 into willothy:main Jun 29, 2023
4 checks passed
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.

None yet

2 participants