-
-
Notifications
You must be signed in to change notification settings - Fork 161
API toggle_current_linewise not working with single line vim.cmd [[<stuff>]] #135
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
Comments
hmmm... that's certainly a issue. There is one subtle difference b/w
I would argue that this is the correct behaviour because inside Well I have to debug this anyway because both of them should behave the same :) |
Wow, I never imagined this issue would be that tricky to solve. This bug is caused by the one difference that I talked about earlier.
You can use this for now and let me know whether this fixes your issue or not require('Comment.api').toggle_current_linewise_op('line') |
I tried using local position = vim.api.nvim_win_get_cursor(0)
vim.api.nvim_command('normal! $')
require('Comment.api').toggle_current_linewise()
vim.api.nvim_win_set_cursor(0, position) I will try and find a proper fix but this would be my first pull request so idk how I'll go haha. |
I tried changing the region for nil vmode to use the first column instead of the current column which will go outside a function U.get_region(vmode)
if not vmode then
-- Added this:
local row = unpack(A.nvim_win_get_cursor(0))
return { srow = row, scol = 0, erow = row, ecol = 0 }
-- Removed this:
-- local row, col = unpack(A.nvim_win_get_cursor(0))
-- return { srow = row, scol = col, erow = row, ecol = col }
end
local m = A.nvim_buf_get_mark
local buf = 0
local sln, eln
if vmode:match('[vV�]') then
sln, eln = m(buf, '<'), m(buf, '>')
else
sln, eln = m(buf, '['), m(buf, ']')
end
return { srow = sln[1], scol = sln[2], erow = eln[1], ecol = eln[2] }
end I have done some testing and it has been working properly. Do you see any issues before I submit a pull request? Thanks! |
Ahh, nice. That should fix the issue. But we need to check this with the treesitter.
Yeah, go ahead we can discuss other issues on the PR itself. |
This issue occurs when the cursor is within the double square brackets in a
vim.cmd [[ <stuff> ]]
When using the
gcc
command on this line, it becomes:-- vim.cmd [[echohl ErrorMsg | echo "Error: Something goofy happened." | echohl None]]
But if you use
lua require('Comment.api').toggle_current_linewise()
, it becomes an incorrect comment:PS. Thanks for the great plugin!
The text was updated successfully, but these errors were encountered: