vscode-cfml icon indicating copy to clipboard operation
vscode-cfml copied to clipboard

Wrong commenting of code in cached components

Open ghost opened this issue 3 years ago • 2 comments

It appears that there is a bug where if component is cached then commenting out code with Ctrl-/ creates wrong comment format, this one // instead of this one <!--- --->. I asked this question on SO.

How to reproduce:

  1. Make sure this
"comments": {
    "lineComment": "<!--- --->",
    "blockComment": [ "<!--- ", " --->" ]
}

is added to language-configuration.json file.

  1. Try commenting out code while components are not cached. For me this worked in 2 ways:
    • Create a new .cfc file, quickly add this code:
    <component>
        <cfset a = "a" />
    </component>
    
    and then quickly hit Ctrl-/ shortcut. It should comment out that line of code properly, like so:
    <component>
        <!--- <cfset a = "a" /> --->
    </component>
    
    A few seconds later try commenting out this line of code again - by this time component should probably be cached by extension - hit comment shortcut key again, it should comment out code in wrong fashion, like so:
    <component>
        // <!--- <cfset a = "a" /> --->
    </component>
    
    • Or second option, open some ColdFusion project and while you see "Cachine components" pop-up running in bottom right corner of VS Code try commenting out some code, it should work. After caching is done and pop-up disappears try commenting code, it should not work from now on.

Now, I understand this may not work on other peoples' machines, maybe something is wrong with my setup, maybe I am wrong about what the problem is and where it lies, but that's all I've got right now.

ghost avatar May 19 '21 13:05 ghost

I found a similar issue in the Ilich CF module, but the opposite way around. I suspect they may use similar parsing logic under the hood so it might be related.

I write my CFCs in CFScript and the short-cut was commenting using HTML comments when I wanted // comments. It wasn't affecting all CFCs, only one file.

It turned out the issue was a comment in my CFC that included CFML markup:

// <cfset everything = 42>

This was way down in the file but it was enough to trick the parser into thinking the file was CFML rather than CFScript.

GeoffCapper avatar Jul 15 '21 05:07 GeoffCapper

@KamasamaK I also am having this issue. Ctrl+\ in a scripted CFC is yielding CFML comments instead of CFScript comments. However, unlike @GeoffCapper, there are no CFM tags in my CFC. When I switched back to to the Illya Verbitskiy CFML extension, I don't have his problem (which is a shame because I like yours better :) ).

robgermain avatar Feb 27 '23 01:02 robgermain