-
-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] When I try to comment linewise in visual mode, unrelated or extra code gets commented #427
Comments
Hmm, when I try to use default keymaps nothing happens. |
I'm having similar behavior, it seems to me that it toggles the previous selection in visual/visual block mode, ignoring the visual line mode selection. ETA: I don't know why I thought this, but it looks like the plugin expects you to leave visual mode before calling |
Surprisingly, I just had a similar dive into how to get visual region. Yeah, this plugin is also making the same mistake, so either nvim changed it recently or just common misconception. Need to either change to {
"<C-_>",
function()
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("<Esc>", true, true, true), "n", true)
require("Comment.api").toggle.linewise(vim.fn.visualmode())
end,
mode = "v",
desc = "Comment selection",
}, |
I just came to the same conclusion. I don't think this plugin is making a mistake so much as just expecting you to exit visual mode first. Trying to adjust the plugin to use |
@Rizhiy for some reason that's not working here. I have the following in my keybinds.lua:
(for some reason option-\ ends up as being « on my system, don't ask). It still comments strange parts of the file in visual mode. |
Here is my config (using lazy):
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:
The text was updated successfully, but these errors were encountered: