hlchunk.nvim icon indicating copy to clipboard operation
hlchunk.nvim copied to clipboard

Add wide/multiple char string and nerd font support for chunk

Open itepechi opened this issue 1 year ago • 1 comments

This PR should fix

  • The rendering glitch that occurs when a non-single cell wide string is passed to the chars option.
  • The rendering glitch that occurs when the virtual text encounters a non-single cell wide character such as control characters, CJK characters, emoji, or nerd font icons.
  • The rendering glitch that occurs when the space is too small to draw both the line and the arrow of the chunk.
  • The rendering glitch caused by "%s" matching non-blank characters and not matching actually blank characters.
  • The rendering glitch caused by vim.api.nvim_strwidth() reporting incorrect string widths.

resolves #134

Demo

main

https://github.com/user-attachments/assets/a7700670-c74e-4650-b536-8c4d826a3b03

This PR

https://github.com/user-attachments/assets/6c5d6314-5678-4339-9baa-aca7b4772120

Real world performance

Performance is better for small to medium files thanks to reduced calls to slow APIs, but worse for large files due to strict checking.

Performance on average

filename main this PR
lua/hlchunk/mods/base_mod/init.lua (199 lines) 0.620 ms 0.522 ms
src/nvim/buffer.c (4254 lines) 1.054 ms 1.265 ms

itepechi avatar Sep 30 '24 17:09 itepechi

Great! thank you very much, however the amount of code involved is indeed quite large, I will take some time to review it further.

shellRaining avatar Oct 01 '24 04:10 shellRaining