You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
API toggle_current_linewise not working with single line vim.cmd [[<stuff>]] #135
changed the title [-]API toggle_current_linewise not working with single line vim.cmd([[ <stuff> ]])[/-][+]API toggle_current_linewise not working with single line vim.cmd [[<stuff>]][/+]on Mar 29, 2022
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.
gcc considers the current column position to end-of-line into its range because it uses a different API require('Comment.api').toggle_current_linewise_op(vim_mode, cfg) whereas require('Comment.api').toggle_current_linewise(cfg) uses the current cursor position as its range.
You can use this for now and let me know whether this fixes your issue or not
I tried using require('Comment.api').toggle_current_linewise_op('line') but it was commenting the whole file so i tried require('Comment.api').toggle_current_linewise_op() but that has the same original issue. What is currently working is:
I tried changing the region for nil vmode to use the first column instead of the current column which will go outside a vim.cmd [[<stuff>]] to get the correct commentstring.
Activity
[-]API toggle_current_linewise not working with single line vim.cmd([[ <stuff> ]])[/-][+]API toggle_current_linewise not working with single line vim.cmd [[<stuff>]][/+]numToStr commentedon Mar 29, 2022
hmmm... that's certainly a issue. There is one subtle difference b/w
gccand the API and maybe that's what causing the issue but I can't say for sure.I would argue that this is the correct behaviour because inside
vim.cmd, treesitter injectsvimscriptthat's why it's using"as the commenstring.Well I have to debug this anyway because both of them should behave the same :)
numToStr commentedon Mar 30, 2022
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.
gccconsiders the current column position to end-of-line into its range because it uses a different APIrequire('Comment.api').toggle_current_linewise_op(vim_mode, cfg)whereasrequire('Comment.api').toggle_current_linewise(cfg)uses the current cursor position as its range.You can use this for now and let me know whether this fixes your issue or not
declancm commentedon Mar 30, 2022
I tried using
require('Comment.api').toggle_current_linewise_op('line')but it was commenting the whole file so i triedrequire('Comment.api').toggle_current_linewise_op()but that has the same original issue. What is currently working is:I will try and find a proper fix but this would be my first pull request so idk how I'll go haha.
declancm commentedon Mar 30, 2022
I tried changing the region for nil vmode to use the first column instead of the current column which will go outside a
vim.cmd [[<stuff>]]to get the correct commentstring.I have done some testing and it has been working properly. Do you see any issues before I submit a pull request? Thanks!
numToStr commentedon Mar 30, 2022
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.