You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 8, 2025. It is now read-only.
There are a couple of mistakes that I think are easy to make in user snippet files. Both could be detected somewhat easily.
Scopes missing initial .
Atom chose early on to treat scope names like CSS class names in many contexts, but it’s not always clear exactly what the expectation is for a specific usage. You can run Editor: Log Cursor Scope and see a list of scopes without initial .s, much like TextMate — e.g., source.js. But any context that uses ScopedPropertyStore under the hood will need the initial dot — e.g., .source.js.
This would be very easy to catch when consuming a user’s snippets file — both on window initialization and after the user makes a change and saves it. If any top-level key does not start with a dot, that’s 100% a mistake. We could also check for missing dots after commas. I don’t think we’d be able to know the exact fix 100% of the time, but just mentioning the problem to the user would be a major improvement over the status quo.
Duplicate keys in snippets.json files
It’s really easy to include a duplicate top-level key in your snippets.cson, but if you do it by accident, we point it out immediately. That’s a huge help. It happens because season has an allowDuplicateKeys option that, when set to false, will throw an error upon encountering a duplicate key.
Sadly, we don’t get this behavior for JSON files. Season will parse JSON files without complaints, but only because it delegates to the built-in JSON.parse when it detects them. So allowDuplicateKeys: false has no effect when parsing a JSON file.
This might not be a big deal. I know we allow a snippets.json file if it exists, but I have no idea how many users choose to reject the default snippets.cson and make a new JSON file. Probably not that many.
What benefits does this feature provide?
More user-friendly, especially to new users. Catches a common mistake before people feel the need to ask for help on GitHub or Discord.
Any alternatives?
One alternative would be to abstract away the difference between (e.g.) source.js and .source.js in all contexts. That would be quite an undertaking, but arguably worth doing. That's a can of worms I won't open right now.
The text was updated successfully, but these errors were encountered:
Have you checked for existing feature requests?
Summary
There are a couple of mistakes that I think are easy to make in user snippet files. Both could be detected somewhat easily.
Scopes missing initial
.
Atom chose early on to treat scope names like CSS class names in many contexts, but it’s not always clear exactly what the expectation is for a specific usage. You can run Editor: Log Cursor Scope and see a list of scopes without initial
.
s, much like TextMate — e.g.,source.js
. But any context that usesScopedPropertyStore
under the hood will need the initial dot — e.g.,.source.js
.This would be very easy to catch when consuming a user’s snippets file — both on window initialization and after the user makes a change and saves it. If any top-level key does not start with a dot, that’s 100% a mistake. We could also check for missing dots after commas. I don’t think we’d be able to know the exact fix 100% of the time, but just mentioning the problem to the user would be a major improvement over the status quo.
Duplicate keys in
snippets.json
filesIt’s really easy to include a duplicate top-level key in your
snippets.cson
, but if you do it by accident, we point it out immediately. That’s a huge help. It happens because season has anallowDuplicateKeys
option that, when set tofalse
, will throw an error upon encountering a duplicate key.Sadly, we don’t get this behavior for JSON files. Season will parse JSON files without complaints, but only because it delegates to the built-in
JSON.parse
when it detects them. SoallowDuplicateKeys: false
has no effect when parsing a JSON file.This might not be a big deal. I know we allow a
snippets.json
file if it exists, but I have no idea how many users choose to reject the defaultsnippets.cson
and make a new JSON file. Probably not that many.What benefits does this feature provide?
More user-friendly, especially to new users. Catches a common mistake before people feel the need to ask for help on GitHub or Discord.
Any alternatives?
One alternative would be to abstract away the difference between (e.g.)
source.js
and.source.js
in all contexts. That would be quite an undertaking, but arguably worth doing. That's a can of worms I won't open right now.The text was updated successfully, but these errors were encountered: