comment-box.nvim icon indicating copy to clipboard operation
comment-box.nvim copied to clipboard

Incorrect handling of inline comments

Open savchenko opened this issue 2 years ago • 3 comments

Steps to reproduce

  1. Create a Lua file:
    { -- Something begins here...
  1. Execute <Cmd>CBllline<CR> while on the line.

Desired result

    { -- Something begins here... ──────────────────────────────────────────────

Actual result

-- ── { -- Something begins here... ──────────────────────────────────────────────

savchenko avatar Jan 14 '24 09:01 savchenko

Yes, the plugin doesn't support inline comments at the moment. I have to mention it in the README.

It's seems kind of tricky to do, but I guess it could be a nice thing to have. I add it to the TODO list. Sorry for the disappointment and thanks for the suggestion!

LudoPinelli avatar Jan 14 '24 18:01 LudoPinelli

No disappointment at all. Would a naive check suffice at first? In pseudocode:

comment_pattern = regex_comment_pattern
comment_pos = line.index(comment_pattern)

if comment_pos then
    apply_comment_box.from(comment_pos)
end

savchenko avatar Jan 14 '24 22:01 savchenko

No disappointment at all. Would a naive check suffice at first? In pseudocode:

comment_pattern = regex_comment_pattern
comment_pos = line.index(comment_pattern)

if comment_pos then
    apply_comment_box.from(comment_pos)
end

Probably, but at the moment, the code only knows the number of the line where the cursor is (or the first and last line selected in visual mode), not the position of the cursor in the line, so I need to implement that.

LudoPinelli avatar Jan 14 '24 23:01 LudoPinelli