LudoPinelli / comment-box.nvim

:sparkles: Clarify and beautify your comments and plain text files using boxes and lines.
MIT License
408 stars 15 forks source link

[Bug] Misalignment due to unstripped input #28

Closed alexmozaidze closed 10 months ago

alexmozaidze commented 11 months ago

Bug

Spaces before input don't get stripped, which results in a misaligned box.

If the input is not a comment, spaces after the input get preserved as well.

Reproduction

  1. Have some input (note the spaces after the input)
    my thing       
--    my thing       
  1. Run :CBalbox on each line
--  ╭──────────────────────╮
--  │      my thing        │
--  ╰──────────────────────╯
--  ╭─────────────╮
--  │    my thing │
--  ╰─────────────╯

Potential solution

Pipe the input through vim.trim()

local input = "    my thing       "
input = vim.trim(input) -- => "my thing"
LudoPinelli commented 10 months ago

Thanks for your feedback! I use vim.trim() but it seems I missed a place where I should have, I'll look into it.

LudoPinelli commented 10 months ago

Fixed, thanks again!