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

Formatting .liquid files deletes their contents #358

Open
joshistoast opened this issue May 14, 2024 · 11 comments
Open

Formatting .liquid files deletes their contents #358

joshistoast opened this issue May 14, 2024 · 11 comments
Labels
Bug Something isn't working moderate lowest severity for theme related bug

Comments

@joshistoast
Copy link

Describe the bug

When both the extension itself and formatOnSave is enabled on liquid files, the entire file is wiped on save.

An issue for this existed but was prematurely closed: #327

Source
Any .liquid file

Expected behavior

Formatting the file

Actual behavior

Deletes all contents of the file

Debugging information

  • OS: MacOS 14.4.1
  • Theme Check Version: 2.3.2

Additional context

Setting formatOnSave to false prevents further deletions of file contents, but doesn't format any files.

{
  ...
  "[liquid]": {
    "editor.defaultFormatter": "Shopify.theme-check-vscode",
    "editor.formatOnSave": false
  },
  ...
}
@mgmanzella
Copy link
Contributor

hi @joshistoast , thanks for reporting this issue 🙏 to confirm, is this happening for all liquid files or just certain ones?? because this doesn't appear to be broken for everyone, this is our current suspicion:

if it’s happening on all liquid files

  • it’s likely an environment issue
  • it can be an issue in the vscode-extension or possibly a conflict with another extension (as mentioned here)

if it’s happening only in some liquid files

  • it’s likely an issue in parser/formatter, then we can get the asset name to reproduce ourselves

lastly if you could share your extension logs, that would also give us more insight about the issue. here's how you can do it in vs code:

getting-logs

thanks in advance for your help as we investigate

@joshistoast
Copy link
Author

@mgmanzella
Within my settings.json

"[liquid]": {
  "editor.defaultFormatter": "Shopify.theme-check-vscode",
  "editor.formatOnSave": true
},
Screen.Recording.2024-05-16.at.12.26.46.PM.mov

The issue is immediately resolved when setting editor.formatOnSave to false

@mgmanzella
Copy link
Contributor

appreciate you sharing that but could you please answer the questions in my previous comment, we need this information to understand what's happening. thanks 🙏

@joshistoast
Copy link
Author

appreciate you sharing that but could you please answer the questions in my previous comment, we need this information to understand what's happening. thanks 🙏

Apologies, it happens in every liquid file

@mgmanzella
Copy link
Contributor

ty! this is likely an issue related to your environment. can you also share the vs code extension logs from your editor for language server

an additional workaround you can try is deactivating other extensions and see if the issue still persists, keep us posted tho 🙏

@joshistoast
Copy link
Author

@mgmanzella language server logs should be in the video on the bottom half of the window.

an additional workaround you can try is deactivating other extensions and see if the issue still persists, keep us posted tho

Did this also but to no avail, but uninstalling the shopify extension in question did solve it.

@mgmanzella
Copy link
Contributor

language server logs should be in the video on the bottom half of the window.

ahhh you're right my bad, do you mind sending the raw logs from language server?? if you dont feel comfortable doing that publicly, feel free to DM me on the partners slack @Morisa Manzella

Did this also but to no avail, but uninstalling the shopify extension in question did solve it.

right which removes liquid prettier from vs code 😭

we'll investigate thanks again for raising 🙏

@mgmanzella mgmanzella added Bug Something isn't working moderate lowest severity for theme related bug labels Jun 18, 2024
@joshistoast
Copy link
Author

Update, editor update on save set to false and my file is still being wiped.

@joshistoast
Copy link
Author

Raw logs:

[SERVER] Let's roll!
Successfully downloaded latest resource:
	https://raw.githubusercontent.com/Shopify/theme-liquid-docs/main/data/latest.json
	> /Users/josh/Library/Caches/theme-liquid-docs-nodejs/latest.json
Successfully downloaded latest resource:
	https://raw.githubusercontent.com/Shopify/theme-liquid-docs/main/data/filters.json
	> /Users/josh/Library/Caches/theme-liquid-docs-nodejs/filters.json
Successfully downloaded latest resource:
	https://raw.githubusercontent.com/Shopify/theme-liquid-docs/main/data/shopify_system_translations.json
	> /Users/josh/Library/Caches/theme-liquid-docs-nodejs/shopify_system_translations.json
Successfully downloaded latest resource:
	https://raw.githubusercontent.com/Shopify/theme-liquid-docs/main/schemas/manifest_theme_app_extension.json
	> /Users/josh/Library/Caches/theme-liquid-docs-nodejs/manifest_theme_app_extension.json
Successfully downloaded latest resource:
	https://raw.githubusercontent.com/Shopify/theme-liquid-docs/main/schemas/manifest_theme.json
	> /Users/josh/Library/Caches/theme-liquid-docs-nodejs/manifest_theme.json
Successfully downloaded latest resource:
	https://raw.githubusercontent.com/Shopify/theme-liquid-docs/main/data/tags.json
	> /Users/josh/Library/Caches/theme-liquid-docs-nodejs/tags.json
Successfully downloaded latest resource:
	https://raw.githubusercontent.com/Shopify/theme-liquid-docs/main/data/objects.json
	> /Users/josh/Library/Caches/theme-liquid-docs-nodejs/objects.json
Successfully downloaded schema:
	https://raw.githubusercontent.com/Shopify/theme-liquid-docs/main/schemas/theme/translations.json
	> /Users/josh/Library/Caches/theme-liquid-docs-nodejs/translations.json
Successfully downloaded schema:
	https://raw.githubusercontent.com/Shopify/theme-liquid-docs/main/schemas/theme/theme_block_entry.json
	> /Users/josh/Library/Caches/theme-liquid-docs-nodejs/theme_block_entry.json
Successfully downloaded schema:
	https://raw.githubusercontent.com/Shopify/theme-liquid-docs/main/schemas/theme/settings.json
	> /Users/josh/Library/Caches/theme-liquid-docs-nodejs/settings.json
Successfully downloaded schema:
	https://raw.githubusercontent.com/Shopify/theme-liquid-docs/main/schemas/theme/default_setting_values.json
	> /Users/josh/Library/Caches/theme-liquid-docs-nodejs/default_setting_values.json
Successfully downloaded schema:
	https://raw.githubusercontent.com/Shopify/theme-liquid-docs/main/schemas/theme/setting.json
	> /Users/josh/Library/Caches/theme-liquid-docs-nodejs/setting.json
Successfully downloaded schema:
	https://raw.githubusercontent.com/Shopify/theme-liquid-docs/main/schemas/theme/section.json
	> /Users/josh/Library/Caches/theme-liquid-docs-nodejs/section.json
Successfully downloaded schema:
	https://raw.githubusercontent.com/Shopify/theme-liquid-docs/main/schemas/theme/theme_settings.json
	> /Users/josh/Library/Caches/theme-liquid-docs-nodejs/theme_settings.json
Successfully downloaded schema:
	https://raw.githubusercontent.com/Shopify/theme-liquid-docs/main/schemas/theme/theme_block.json
	> /Users/josh/Library/Caches/theme-liquid-docs-nodejs/theme_block.json
Successfully downloaded schema:
	https://raw.githubusercontent.com/Shopify/theme-liquid-docs/main/schemas/theme/app_block_entry.json
	> /Users/josh/Library/Caches/theme-liquid-docs-nodejs/app_block_entry.json
Successfully downloaded schema:
	https://raw.githubusercontent.com/Shopify/theme-liquid-docs/main/schemas/theme/local_block_entry.json
	> /Users/josh/Library/Caches/theme-liquid-docs-nodejs/local_block_entry.json
Successfully downloaded schema:
	https://raw.githubusercontent.com/Shopify/theme-liquid-docs/main/schemas/theme/targetted_block_entry.json
	> /Users/josh/Library/Caches/theme-liquid-docs-nodejs/targetted_block_entry.json
Loaded resource from /Users/josh/Library/Caches/theme-liquid-docs-nodejs/manifest_theme.json
Loaded resource from /Users/josh/Library/Caches/theme-liquid-docs-nodejs/manifest_theme_app_extension.json
Loaded schema from /Users/josh/Library/Caches/theme-liquid-docs-nodejs/translations.json
Loaded schema from /Users/josh/Library/Caches/theme-liquid-docs-nodejs/theme_block.json
Loaded schema from /Users/josh/Library/Caches/theme-liquid-docs-nodejs/theme_settings.json
Loaded schema from /Users/josh/Library/Caches/theme-liquid-docs-nodejs/section.json
Loaded schema from /Users/josh/Library/Caches/theme-liquid-docs-nodejs/settings.json
Loaded schema from /Users/josh/Library/Caches/theme-liquid-docs-nodejs/setting.json
Loaded schema from /Users/josh/Library/Caches/theme-liquid-docs-nodejs/default_setting_values.json
Loaded schema from /Users/josh/Library/Caches/theme-liquid-docs-nodejs/app_block_entry.json
Loaded schema from /Users/josh/Library/Caches/theme-liquid-docs-nodejs/theme_block_entry.json
Loaded schema from /Users/josh/Library/Caches/theme-liquid-docs-nodejs/targetted_block_entry.json
Loaded schema from /Users/josh/Library/Caches/theme-liquid-docs-nodejs/local_block_entry.json
Loaded schema from /Users/josh/Library/Caches/theme-liquid-docs-nodejs/translations.json
Loaded resource from /Users/josh/Library/Caches/theme-liquid-docs-nodejs/filters.json
Loaded resource from /Users/josh/Library/Caches/theme-liquid-docs-nodejs/shopify_system_translations.json
Loaded resource from /Users/josh/Library/Caches/theme-liquid-docs-nodejs/tags.json

@charlespwd
Copy link
Contributor

More context: #586 (comment)

Maybe it's WSL related? How is this happening? We're supposed to not do anything when there's an error. Why would prettier.format return the empty string without error?

@jpallard6120
Copy link

@charlespwd Thanks for moving this here! Happy to give more context if necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working moderate lowest severity for theme related bug
Projects
None yet
Development

No branches or pull requests

4 participants