-
Notifications
You must be signed in to change notification settings - Fork 199
VS Code Extension not auto-closing quotes on ERB files #3504
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
Comments
The problem seems to occur specifically within tags when defining things such as CSS class. |
Thanks for the report! This is likely some issue with our ERB language configuration for auto closing pairs. |
This behaviour is related to Auto closing before configuration of the language. As vscode says "By default, VS Code only autocloses pairs if there is whitespace right after the cursor.". Example: <h1>|</h1> Will not autoclose the configured auto closing pairs. It is possible to add the character
I belive the cons are worse. So in my opinion if its really needed the user can set the configuration "[erb]": {
"editor.autoClosingQuotes": "always",
"editor.autoClosingBrackets": "always", # This also if brackets are also wanted.
} On the other hand, when the cursor is in ¿Do you guys see any border case that could give wierd behaviour? |
Is it possible to configure the auto close to happen only inside ERB tags ( I agree that in other cases, the experience will likely be worse. |
The behaviour could be double-quote only, or have separate configuration for double and single quotes to avoid problems with apostrophes. Alternatively the auto-closing can occur only within a |
I researched a little more here. The problem seems related to this issue in the VSCode implementation for embedded languages. If we look at the grammar in In the case that bug is resolved, the grammars in this repository should be updated for each to have the correct auto closing configuration for each language, the erb host, and the ruby embedded. But the issue is from 2021 so probably is not going to be solved any soon. |
Another thing to consider is that when working on embedded languages when the cursor is just before the closing tag, the language is still the host language. Here are some exaples for ERB and for Markdown Case 1: So even if the issue get's solved we are still in the erb context when typing "<%" because we land at case 2. This could be improved by adding "autoClosingPairs": [
...
["<% ", " %>"],
...
]
"autoCloseBefore": ";:.,=}])> \n\t%", Based on the default autoCloseBefore we only add Here I have a demo that showcase that configuration: Before: Screencast.from.27-05-25.23.39.06.webmAfter: Screencast.from.27-05-25.23.35.15.webm |
Description
Ruby LSP Information
VS Code Version
1.100.1
Ruby LSP Extension Version
0.9.24
Ruby LSP Server Version
0.23.20
Ruby LSP Add-ons
Ruby Version
3.4.3
Ruby Version Manager
mise
Installed Extensions
Click to expand
Ruby LSP Settings
Click to expand
Workspace
User
Reproduction steps
The text was updated successfully, but these errors were encountered: