Closed Aerijo closed 4 years ago
@lee-dohm @lkashef bump. I played with this PR for a while and feel that this fairly works well.
@aviatesk Progress is happening; we're aiming to split it into smaller, more manageable PRs. The decaffeination of the remaining files is the first step.
This PR was too big. I tried splitting it off into smaller PRs, but it was still much easier to just write a new package from the ground up. Many of the changes in this PR have already been added to the new package, and things like cleaner undo/redo are on my radar. Once (if) it matures, I may revisit making changes to this package, but for now I'm focusing all my snippet efforts on the new package.
NOTE: Ready for review
Requirements
Description of the Change
Redoes a lot of stuff. Basic idea is to comply with the VS Code spec (based on TextMate spec; also used by Sublime Text) as much as possible, because that's the spec language servers are supposed to use. With this, we'll fully support well formed LSP snippets. The added features are also useful anyway, and following an existing spec means we don't have to define our own (though I believe it's all based off of TextMate anyway).
Putting this up now for feedback and trying it out while it's still being worked on.
Added
Changed
g
flag from transformation regex. If users want it, they can add it explicitly. And now, if they don't want it, they have a choice.\
only escapes the characters$
,}
, and\
(and a few others depending on context).g
flag where the implicit one was relied upon.SnippetExpansion
, which is a temporary representation for the expanded snippet.snippet.getTabStops
into something more modular. Currently renamed totoString
, but it will make the insertion string and tab stops.editor.transact
calls; these appeared to only make the undo behaviour fail in strange ways.Open Questions
[ ] Should\
escape everything? It would make it easier to remember what it does, but subtly break VS Code compatibility (which is slightly different in a few areas anyway). It would also simplify the grammar.Alternate Designs
Would have removed
\u
and co flags entirely, but they appear to be supported by TextMate too and so are worth keeping.Benefits
99% backwards compatible, and adds much more advanced and dynamic capabilities. With custom variable resolvers, users can do pretty much anything with the provided text editor (and any other relevant params).
Possible Drawbacks
Bodies that contained text like
${1|one,two,three|}
will now be interpreted, instead of being a literal. But 1. the fix is to escape the$
like this\\${1|one,two,three|}
(as the raw CSON value), and 2. no one* would be doing that unless they wanted a choice placeholder anyway.*me
Applicable Issues
Closes #287 (this also contains the decaffeination changes)
Closes #285
Also closes #41 I think
Closes https://github.com/atom/apm/issues/213. That conversion uses alternate replacement syntax
(?1:=:=)
that now has support added here too.