-
Notifications
You must be signed in to change notification settings - Fork 22
Enable editor::WrapSelectionsInTag action in HTML+ERB files
#191
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
Conversation
|
@janko looks great! Can you please check the pipeline before we merge this? Thanks! |
c888312 to
383b316
Compare
|
@vitallium Fixed ✅ |
Awesome, thank you! |
|
Aaand I failed to land the proper commit because of GitHub: |
|
@vitallium It seems this didn't fix the issue – the EDIT: Claude Code is suggesting adding LLM output |
Hi! Do you have an example? Handling of ERB templates is quite tricky because of how Zed parses them. Consider the following example: <div>Hi!</div>
<%= tag.div(flash[:alert], style: "color:red") if flash[:alert] %>The 1st line uses ERB grammar, so it uses everything applicable to |
|
If I take your example, and put it in an This is the behavior that I get if I change the language from |
Ah, I remember now. Good news: this is an issue with Zed itself. The
That works for 90% of languages, but ERB is special. ERB is not a language technically; it’s a configuration of ERB that produces a syntax tree consisting of two languages via injections: HTML and Ruby. The final syntax tree can be treated as one that includes both languages. Zed parses the file using the provided tree-sitter grammar, which includes HTML and Ruby injections. Zed uses these to load the corresponding grammars for each language. This results in three languages being used in an editor that displays an ERB template:
When Zed asks for the underlying language at a given point, it simply uses the last available language, which is Bad news: the last time I checked the corresponding issue upstream, there was no progress because this functionality is a core feature and changing it could be risky. Also, since we don’t have many languages with such unusual grammar parsing, this issue has low priority. Sorry that such a simple and useful feature doesn’t work in Zed due to this issue. I hope it will be fixed someday. Thanks! |
|
Appreciate the detailed explanation 🙏🏻 I opened zed-industries/zed#40632, so we'll see if that helps. |
I believe this is what's needed to enable the
editor::WrapSelectionsInTagaction in HTML+ERB files. It worked on initial release, but I think at some point the implementation was generalized by letting languages specifywrap_characters, so currently it only works in pure HTML files.