Skip to content

Issue with injected language #144

Closed
Closed

Description

@gegoune

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

Activity

  1. numToStr commented on Apr 17, 2022

    @numToStr
    Owner

    This is kinda similar to #135

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

  2. gegoune commented on Apr 17, 2022

    @gegoune
    Author

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

  3. numToStr commented on Apr 17, 2022

    @numToStr
    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.

  4. numToStr commented on Apr 19, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    wontfixThis will not be worked on

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions