Skip to content
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

Issue with injected language #144

Closed
gegoune opened this issue Apr 17, 2022 · 4 comments
Closed

Issue with injected language #144

gegoune opened this issue Apr 17, 2022 · 4 comments
Labels
wontfix This will not be worked on

Comments

@gegoune
Copy link

gegoune commented Apr 17, 2022

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.

(thanks for great plugin!)

@numToStr
Copy link
Owner

This is kinda similar to #135

Could you try to recreate the same with vim.cmd[[stopinsert!]] or vim.cmd('stopinsert!')?

@gegoune
Copy link
Author

gegoune commented Apr 17, 2022

Both work fine, as in, comments out entire line with -- .

@numToStr
Copy link
Owner

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.

@numToStr
Copy link
Owner

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 :)

@numToStr numToStr added the wontfix This will not be worked on label Apr 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants