-
-
Notifications
You must be signed in to change notification settings - Fork 200
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
Implement 'Synced Regions' for Svelte #726
Comments
The markup part would be easy to implement and it probably is what it's designed for. The svelte control flow is viable but probably only possible when there's no syntax error in the file. |
I tried to implement the svelte control flow but the result using svelte AST is not very useful. It's too brittle. During linked editing, the code is very likely to be invalid. So the svelte compiler keeps complaining. We might need to implement a dedicated parser for it to be useful. So this probably won't happen soon. To be clear, it does work. But once you exit for the linked editing mode, you can't go back because the code is invalid. So you will have to type quickly and correctly before vscode exit the linked editing mode. |
I also think that using the Svelte AST will be too brittle. Writing a custom parser sound like too much work for such a feature. Maybe the html parser we use in other places could be used for that. |
Element and component tag can be done by the html-language-service. Not much code needed but there is a weird problem I just can't find out why. |
This feature is now live for html tags. Still not sure if other areas are valid use cases. |
HTML for VS Code recently introduced Synced Regions for HTML tags. In summary, if you edit an opening tag, the same edits appear in the closing tag and vice versa.
This API is available for other extensions as of two weeks ago.
This is an issue to track the implementation of Synced Regions for: (Tip:
|
is the cursor)<div|></div|>
){#each| n}{/each|}
).<div class="apple|"></div> <style> .apple| {color: red}</style>
)<script> let world| = "" </script><div>Hello {world|}</div>
.<script> import Component| from "./component"</script><Component|></Component|>
** Syncing JavaScript and CSS classes and ids is iffy since I can imagine wanting to edit a variable/class without changing others in many situations. I haven't experimented with how flexible the
LinkedEditingRangeProvider
API is, but if possible, we could require a key-binding to get into synced mode for these contentious regions. Requiring a key-binding will likely hurt feature discovery + usage of syncing for these regions, so discussion of other possible implementations is very welcome.I'd suggest four separate settings options for HTML, flow control, CSS and JS. Where HTML & flow control are on by default, but CSS & JS are off by default.
The text was updated successfully, but these errors were encountered: