Skip to content

[BUG] When I try to comment linewise in visual mode, unrelated or extra code gets commented #427

@Rizhiy

Description

@Rizhiy

Here is my config (using lazy):

return {
    "numToStr/Comment.nvim",
    keys = {
        {
            "<C-_>",
            function()
                require("Comment.api").toggle.linewise.current()
                require("rizhiy.keys").press("j", "n")
            end,
            desc = "Comment line",
        },
        {
            "<C-_>",
            function() require("Comment.api").toggle.linewise(vim.fn.visualmode()) end,
            mode = "v",
            desc = "Comment selection",
        },
    },
    opts = {
        mappings = {
            basic = false,
        },
    },
}

When I try to comment in visual mode (using C-/), different code rather than selection gets commented, sometimes the outer scope, sometimes completely unrelated code altogether.

This config was working previously, not sure what changed.

vim version:

NVIM v0.9.4
Build type: Release
LuaJIT 2.1.1692716794

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions