💡 RFC: Add code fix to replace quotes with curly braces #868
nojaf
started this conversation in
Feature requests
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Background & Motivation
When typing code in the JSX-like syntax, I often need to wrap a property assignment in
{
}
.Where autocomplete inserts
"
"
after pressing=
.It would be great if we had a code action to change the empty quotes to empty curly braces.
Proposed Solution
Possible solutions
As was mentioned on Discord, this could be a code action in
provideCodeActions
in https://github.com/withastro/language-tools/blob/main/packages/language-server/src/plugins/astro.ts.Alternatives considered
/
Risks, downsides, and/or tradeoffs
I don't have enough insights to say anything about this.
Open Questions
/
Detailed Design
Inside the code action, I would assume I can get the cursor position and then try to find the current AST node. If that node is this empty quotes of a property assignment, the code action should kick in. Or that is how I naively would approach the problem.
Does this make sense? If so, how would I get the AST nodes?
Help make it happen!
Beta Was this translation helpful? Give feedback.
All reactions