Closed akinsho closed 2 years ago
Thank you Akin!! I discovered this too, and I have already fixed it in my local repo. However, I did not know about vim.api.nvim_strwidth()
; I was using vim.fn.strchars()
. And now that I'm looking at it, I probably was using the wrong function anyway, since there is also vim.fn.strdisplaywidth()
. I will take your lead and change to using nvim_strwidth
because I'd rather use the nvim API whenever possible.
Sorry for not pushing my changes sooner! I am going to create a develop
branch and start pushing my commits there as I make them.
No worries @b0o I'll close this out and await your fix 👍🏾
Whilst messing about with a more jazzy winline 👇🏿 I noticed that it was rendering with a much longer window than necessary because I was using icons. Applying this fix gives the correct length for the string passed in.
This image is of the corrected string.
This is because Lua's # or len function count the number of bytes rather than the cells that a string will occupy. This means that it will often over count the size of a string for usecases like TUI elements in nvim
The function to create this is