WilliamVenner / vscode-glua-enhanced

👨‍💻 Garry's Mod Lua VSCode Extension for enhanced auto completion, wiki integration, snippets, color palette, and much more...
https://marketplace.visualstudio.com/items?itemName=venner.vscode-glua-enhanced
GNU General Public License v3.0
401 stars 10 forks source link

Incompatiblity with maptz.regionfolder #56

Open TheOnly8Z opened 1 year ago

TheOnly8Z commented 1 year ago

I tried using RegionFolder with a custom configuration to be able to fold my code blocks. GLua files seem to prevent this extension from creating fold spaces even though the same file and configuration works with regular Lua. https://marketplace.visualstudio.com/items?itemName=maptz.regionfolder

To Replicate

I am using the following configuration for this extension in settings.json. This setup is identical to the one in the extension, but renamed for glua instead of lua.

    "maptz.regionfolder": {
        "[glua]": {
            "foldEnd": "--#endregion",
            "foldEndRegex": "--[\\s]*#endregion",
            "foldStart": " --#region [NAME]",
            "foldStartRegex": "--[\\s]*#region[\\s]*(.*)"
        }
    },

When the file is configured as GLua (bottom right language setting), the folding widgets do not appear even though regions are defined correctly. image

After switching language to Lua, the fold widgets immediately become visible and can be used to collapse code. image image

If I switch back to GLua without folding anything, the fold widgets disappear.

Curiously however, if the fold regions are folded before switching from Lua to GLua, they remain folded and can be used without disappearing, persisting even after the file is closed and reopened and within new windows.

image

The ability to fold certain user-defined regions is super convenient for large, sectioned bulk files that have segments but no code blocks for each. If this can be resolved (or something similar implemented into GLua Enhanced) it'd be a great producibility tool.

WilliamVenner commented 1 year ago

The extension has to register a new "language" in order for GLua Enhanced to not load when editing normal Lua files, therefore, extensions for the Lua language will not work with the GLua language

TheOnly8Z commented 1 year ago

The extension has to register a new "language" in order for GLua Enhanced to not load when editing normal Lua files, therefore, extensions for the Lua language will not work with the GLua language

That is true, and I have set custom configuration for the extension to make it work with GLua.

In addition to the above issue, I also noticed that when both extensions are active, GLua Enhanced can't generate its own folding widgets for functions and code blocks. My guess is that this seems to be related to two extensions modifying folding behavior at the same time.