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

[Bug] Wrong block comment on visual line mode

Open jjant opened this issue 2 years ago • 1 comments

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();
} */

jjant avatar Aug 26 '22 10:08 jjant

Reproduced. I'll have a look. Thanks for reporting.

numToStr avatar Aug 26 '22 10:08 numToStr

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

numToStr avatar Sep 23 '22 13:09 numToStr

Nice find, @numToStr!

jjant avatar Sep 23 '22 14:09 jjant

Hopefully 70615e63a6dcc41de0e90a7d79bdcec511bda93f fixes this issue :)

numToStr avatar Sep 23 '22 14:09 numToStr