Skip to content

Conversation

@simonhaenisch
Copy link
Owner

Still work-in-progress, doesn't actually work yet (see failing test).

Would close #39.

@johnsoncodehk
Copy link
Contributor

It seem getScriptSnapshot giving invalid svelte content.

螢幕截圖 2022-10-20 17 30 33

<scriptprettier:content✂="CgkJaW1wb3J0IEZvbyBmcm9tICcuL0Zvby5zdmVsdGUnOwoJCWltcG9ydCBCYXIgZnJvbSAnLi9CYXIuc3ZlbHRlJzsKCQlpbXBvcnQgVW51c2VkIGZyb20gJy4vVW51c2VkLnN2ZWx0ZSc7Cgk=">{}</script>

	<Foo />
	<Bar />

@johnsoncodehk
Copy link
Contributor

If you need to debug, you can add breakpoint at node_modules/@volar/language-core/out/languageContext.js line 139.

@simonhaenisch
Copy link
Owner Author

simonhaenisch commented Nov 9, 2022

It seem getScriptSnapshot giving invalid svelte content.

Actually, what you're seeing there is what Prettier passes to the plugin as code argument, and I'm assuming it comes from prettier-plugin-svelte. That base64 string is the encoded version of the script's actual value. Not very familiar with svelte tooling but I'll try to dig deeper when i find some more time for this.

Edit: this is what's doing this: https://github.com/sveltejs/prettier-plugin-svelte/blob/master/src/lib/snipTagContent.ts. I guess I could manually call that unsnipContent function that's exported there, just wondering whether it's a good approach 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature request] Add Svelte support

4 participants