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

VSCode auto formatter compresses each loop to single line #117

Closed
georgebzhang opened this issue Aug 12, 2020 · 2 comments · Fixed by #160
Closed

VSCode auto formatter compresses each loop to single line #117

georgebzhang opened this issue Aug 12, 2020 · 2 comments · Fixed by #160

Comments

@georgebzhang
Copy link

{#each items as item}
{item}
{/each}

gets automatically formatted (Option + Shift + F) in VSCode to

{#each items as item}{item}{/each}

Would much prefer if the auto formatter did not compress the each loop to a single line.

OS: Macbook Pro 2018
IDE: VSCode
Plugin/Package: Svelte for VSCode

Requested to forward this issue to prettier-plugin-svelte: sveltejs/language-tools#451

@bholtbholt
Copy link

This occurs in Sublime Text 3 as well

@dummdidumm
Copy link
Member

A workaround is to add <!-- prettier-ignore --> above the {#each..:

<!-- prettier-ignore -->
{#each items as item}
    {item}
{/each}

dummdidumm pushed a commit to dummdidumm/prettier-plugin-svelte that referenced this issue Nov 9, 2020
Goals:
- switch logic around: prepare nodes before printing docs, try to avoid modifying printed result
- respect user's wish to have line breaks sveltejs#143 sveltejs#117
- generally try to be more in line with how prettier formats things

TODO:
- either get tag break logic on par with prettier (breaking > into new lines etc) or adjust tests
- more readable tag breaking logic for multiple children tags
- tidy up
dummdidumm added a commit that referenced this issue Jan 2, 2021
Goals:

- switch logic around: prepare nodes before printing docs, try to avoid modifying printed result
- respect user's wish to have line breaks: fixes #143, fixes #117, closes #121
- generally try to be more in line with how prettier formats things

### BREAKING CHANGE
Tags are broken up differently now than before
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants