vscode-better-folding icon indicating copy to clipboard operation
vscode-better-folding copied to clipboard

Feature request: support .svelte files

Open unikitty37 opened this issue 2 years ago • 2 comments

Is your feature request related to a problem? Please describe. When editing a Svelte component, many blocks are not foldable when using Better Folding. They are foldable when Better Folding is disabled.

Specifically, a Svelte component contains zero or more <script> blocks and zero or more <style> blocks as well as normal HTML. It can also contain conditional blocks: {#if condition} … {:else} … {/if}.

Describe the solution you'd like I'd like it if Better Folding supported Svelte, as this is what I'm mainly developing in. I prefer the way Better Folding folds things when I'm using file formats it supports, but having it not work with Svelte is a bit of a blocker for me…

Describe alternatives you've considered Currently, I've disabled Better Folding so I can use the Visual Studio Code default folder, which loses the Better Folding improvements, but works with Svelte.

The only other alternative I could think of would be to surround blocks I want to fold with region comments, but this is a bit of a hack (and leads to complaints if any of them get committed, as other devs "don't want IDE-specific stuff in the codebase" 🙄)

Additional context

Changing the extension to .html makes Svelte blocks foldable with Better Folding, so enabling this support for .svelte files would at least let me collapse a long <style> block when I don't need to see it. Adding support for the other Svelte-specific stuff like {#if} … {:else} … {/if} could come later.

With Better Folding disabled:

image

With Better Folding enabled:

image

With Better Folding enabled, and the file type changed to .html:

image

unikitty37 avatar Mar 19 '23 12:03 unikitty37

Hey, thanks for making such a detailed issue.

Svelte is definitely on the upcoming supported languages, hopefully soon(ish).

As a temporary fix, did you try adding svelte to the excluded languages list in the settings?

mtbaqer avatar Mar 19 '23 18:03 mtbaqer

Thanks — I hadn't spotted that setting. That's helped for now 👍

unikitty37 avatar Mar 21 '23 14:03 unikitty37