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
Hey, have noticed that if you have a cursor inside string such as (lua file example)
vim.cmd'stopinsert!'
commanding gcc leads to incorrectly commented out line:
" vim.cmd 'stopinsert!'
I am not quite sure if I would expect it to turn to
vim.cmd'" stopinsert!'
or simply do nothing (perhaps it should comment out injected code, as it would make sense within multilane blocks). But correct behaviour is surely wrong.
As I suspect, the thing with gcc is that it takes the range from the current cusor possition to the end of line and uses that to detects the language.
So with vim.cmd 'stopinsert!', gcc was only able to detect vim and used " as the commentstring. But with vim.cmd('stopinstert!'), the last char i.e ) is Lua so gcc then used ---
This situation, two languages on the same line, will always be ambiguous. And I don't even know whether is this something that needs to be fixed or not.
Activity
numToStr commentedon Apr 17, 2022
This is kinda similar to #135
Could you try to recreate the same with
vim.cmd[[stopinsert!]]orvim.cmd('stopinsert!')?gegoune commentedon Apr 17, 2022
Both work fine, as in, comments out entire line with
--.numToStr commentedon Apr 17, 2022
As I suspect, the thing with
gccis that it takes the range from the current cusor possition to the end of line and uses that to detects the language.So with
vim.cmd 'stopinsert!',gccwas only able to detect vim and used"as the commentstring. But withvim.cmd('stopinstert!'), the last char i.e)is Lua sogccthen used---This situation, two languages on the same line, will always be ambiguous. And I don't even know whether is this something that needs to be fixed or not.
numToStr commentedon Apr 19, 2022
I am closing this for now. As I don't know a solution that'll work in every case. If anyone figures this out feel free to reply or even raise a PR :)