-
Notifications
You must be signed in to change notification settings - Fork 29
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
Feature/preset block settings completion #732
base: main
Are you sure you want to change the base?
Conversation
3d3ab01
to
1ca8046
Compare
1ca8046
to
e875edf
Compare
e875edf
to
820091c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -169,7 +169,7 @@ export class DocumentManager { | |||
if (!this.getModeForUri || !this.isValidSchema) return undefined; | |||
|
|||
const mode = await this.getModeForUri!(uri); | |||
return toSchema(mode, uri, sourceCode, this.isValidSchema); | |||
return toSchema(mode, uri, sourceCode, this.isValidSchema, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great question! This is definitely going to be a controversial take here. Would love to get @charlespwd 's opinion on it before i merge.
- Our default schema parser is very strict (does not like any syntax errors)
- But if you are a dev who's typing their schema, you're going to have syntax errors while typing.
- E.g. You haven't provided a value for the key you are about to type
"presets": [ { "settings": { "█" } } ]
- You need auto-completion to type inside that quotes, but since your schema is invalid, all auto-completion gets disabled (BAD)
- We need less strict JSON parsing (at least during completion, hovers, etc.) BUT not during theme checks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah! That makes sense to me I think. Not sure what else we could do otherwise, tbh.
* The PresetsBlockSettingsPropertyCompletionProvider offers value completions of the | ||
* `presets.[].(recursive blocks.[]).settings` keys inside section and theme block `{% schema %}` tags. | ||
* | ||
* @example |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love including the description and example here. I will add this to the branch I'm working on!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth adding tests specifically for this function?
import { Translations } from '@shopify/theme-check-common'; | ||
|
||
export function schemaSettingsPropertyCompletionItems( | ||
parsedSchema: any, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we able to get rid of the any
s in here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, valid schemas returned from getSchema
are any
so not much i can do here.
What are you adding in this PR?
Fixes #623
Testing
example:
What's next? Any followup issues?
Pickup remaining tasks under #545
Before you deploy
changeset