Comment.nvim
Comment.nvim copied to clipboard
[Bug] Wrong block comment on visual line mode
Description
Hi, forgive me if this is just me expecting the wrong thing, but in this rust file:
fn f() {}
If I select the line with the function and comment block: Vgb
, I get this:
/* */fn f() {}
When I expected:
/* fn f() {} */
Line comment mode works as I expect it: Vgc
results in // fn f() {}
.
Note
The wrong behaviour seems to happen when selecting exactly 1 line, if I select more, I get what I expect:
fn f() {
something();
}
// V2jgb
/* fn f() {
something();
} */
Reproduced. I'll have a look. Thanks for reporting.
The reason for this bug is when you enter VISUAL LINE
mode, in our case, '<
and '>
mark gives you 0
and 2147483647
respectively and we are using string.sub({line}, 0, 2147483647 + 1)
to get the substring but LuaJIT implementation of string.sub
return empty string because of interger casting in luajit code itself. So, we have handle this ourselves.
Ref https://github.com/LuaJIT/LuaJIT/issues/674
Nice find, @numToStr!
Hopefully 70615e63a6dcc41de0e90a7d79bdcec511bda93f fixes this issue :)