nvim-comment-frame icon indicating copy to clipboard operation
nvim-comment-frame copied to clipboard

Border does not alignment at the end

Open fgheng opened this issue 3 years ago • 7 comments
trafficstars

image

fgheng avatar May 13 '22 08:05 fgheng

Can we just wait until 5.3 lua integration so we have unicode support 😂🥲

s1n7ax avatar May 20 '22 08:05 s1n7ax

So if I use nerdfonts icons or emojis in the comment line, it may cause problems?

charliie-dev avatar Oct 09 '22 13:10 charliie-dev

@CharlesChiuGit I think it will. It's about how lua calculates the length of a string. At the moment, lua version embedded into Neovim does not support unicode. So string length is number of bytes in the string which is invalid for unicode characters except for really small fraction of the letters (everything in ASCII is backward compatible so they work). That's why for English but may now work for most other languages

s1n7ax avatar Oct 10 '22 09:10 s1n7ax

@s1n7ax Thanks for the explaination! But for some reason it not aligned.

image

In text:

----------------------------------------------------------------------
--                  :treesitter related plugins                  --
----------------------------------------------------------------------
----------------------------------------------------------------------
--                    treesitter related plugins                    --
----------------------------------------------------------------------

charliie-dev avatar Oct 10 '22 09:10 charliie-dev

Just elaborating on the issue again. Following is getting the length of the character using Lua vs JavaScript. As you can see, JavaScript counts the characters while lua counts the number of bytes. This is why the frame is not aligning. To fix this I'm going to have to add external dependency to support UTF-8.

image image

s1n7ax avatar Oct 13 '22 04:10 s1n7ax

I'm considering adding unicode support to the plugin in the future.

s1n7ax avatar Oct 13 '22 04:10 s1n7ax

Sounds cool! Using unicode does seems like a better solution to this. But might still fail at some some edge cases since encoding is such a huge problem. Thanks for your investigation!

charliie-dev avatar Oct 13 '22 04:10 charliie-dev