Shopify / theme-tools

Everything developer experience for Shopify themes
https://shopify.dev/docs/themes
MIT License
47 stars 14 forks source link

Formatting `.liquid` files deletes their contents #358

Open joshistoast opened 1 month ago

joshistoast commented 1 month ago

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

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 commented 1 month ago

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

if it’s happening only in some liquid files

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 commented 1 month ago

@mgmanzella Within my settings.json

"[liquid]": {
  "editor.defaultFormatter": "Shopify.theme-check-vscode",
  "editor.formatOnSave": true
},

https://github.com/Shopify/theme-tools/assets/23065423/8509dc3b-a7ee-494a-abe6-0a3497d6264a

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

mgmanzella commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

@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 commented 1 month ago

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 πŸ™

joshistoast commented 2 weeks ago

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

joshistoast commented 2 weeks ago

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