Skip to content

Commit 5d4141c

Browse files
Properly handle snippet migration with multiple different snippets in one file and noop phrase (#2838)
Fixes #2836 Fixes #2840 Input ```json { "mobxConstructor": { "definitions": [ { "scope": { "langIds": [ "typescript", "javascript", "typescriptreact", "javascriptreact" ] }, "body": [ "constructor($parameters) {", "\tmakeAutoObservable(this);", "}" ] } ], "description": "Constructor using makeAutoObservable", "insertionScopeTypes": [ "namedFunction" ] }, "constantDeclaration": { "definitions": [ { "scope": { "langIds": [ "typescript", "javascript", "typescriptreact", "javascriptreact" ] }, "body": [ "const $name = ${value/^([^;]*);?$/$1/};" ], "variables": { "name": { "formatter": "camelCase" } } } ], "description": "Constant variable declaration", "insertionScopeTypes": [ "statement" ], "variables": { "value": { "wrapperScopeType": "statement" } } }, "constantDeclarationWithType": { "definitions": [ { "scope": { "langIds": [ "typescript", "javascript", "typescriptreact", "javascriptreact" ] }, "body": [ "const $name: $type = ${value/^([^;]*);?$/$1/};" ], "variables": { "name": { "formatter": "camelCase" } } } ], "description": "Constant variable declaration with type", "insertionScopeTypes": [ "statement" ], "variables": { "value": { "wrapperScopeType": "statement" } } }, "letDeclaration": { "definitions": [ { "scope": { "langIds": [ "typescript", "javascript", "typescriptreact", "javascriptreact" ] }, "body": [ "let $name = ${value/^([^;]*);?$/$1/};" ], "variables": { "name": { "formatter": "camelCase" } } } ], "description": "Let variable declaration", "insertionScopeTypes": [ "statement" ], "variables": { "value": { "wrapperScopeType": "statement" } } }, "letDeclarationWithType": { "definitions": [ { "scope": { "langIds": [ "typescript", "javascript", "typescriptreact", "javascriptreact" ] }, "body": [ "let $name: $type = ${value/^([^;]*);?$/$1/};" ], "variables": { "name": { "formatter": "camelCase" } } } ], "description": "Let variable declaration with type", "insertionScopeTypes": [ "statement" ], "variables": { "value": { "wrapperScopeType": "statement" } } } } ``` Output ``` name: mobxConstructor description: Constructor using makeAutoObservable language: typescript | javascript | typescriptreact | javascriptreact insertionScope: namedFunction - constructor($parameters) { makeAutoObservable(this); } --- name: constantDeclaration description: Constant variable declaration language: typescript | javascript | typescriptreact | javascriptreact insertionScope: statement $name.insertionFormatter: PRIVATE_CAMEL_CASE $value.wrapperScope: statement - const $name = ${value/^([^;]*);?$/$1/}; --- name: constantDeclarationWithType description: Constant variable declaration with type language: typescript | javascript | typescriptreact | javascriptreact insertionScope: statement $name.insertionFormatter: PRIVATE_CAMEL_CASE $value.wrapperScope: statement - const $name: $type = ${value/^([^;]*);?$/$1/}; --- name: letDeclaration description: Let variable declaration language: typescript | javascript | typescriptreact | javascriptreact insertionScope: statement $name.insertionFormatter: PRIVATE_CAMEL_CASE $value.wrapperScope: statement - let $name = ${value/^([^;]*);?$/$1/}; --- name: letDeclarationWithType description: Let variable declaration with type language: typescript | javascript | typescriptreact | javascriptreact insertionScope: statement $name.insertionFormatter: PRIVATE_CAMEL_CASE $value.wrapperScope: statement - let $name: $type = ${value/^([^;]*);?$/$1/}; --- ``` --------- Co-authored-by: Pokey Rule <[email protected]>
1 parent be953a5 commit 5d4141c

File tree

4 files changed

+584
-64
lines changed

4 files changed

+584
-64
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"link": {
3+
"definitions": [
4+
{
5+
"scope": {
6+
"langIds": [
7+
"markdown"
8+
]
9+
},
10+
"body": [
11+
"[$text](${url:$CLIPBOARD})"
12+
]
13+
},
14+
{
15+
"scope": {
16+
"langIds": [
17+
"typescript",
18+
"javascript",
19+
"typescriptreact",
20+
"javascriptreact"
21+
]
22+
},
23+
"body": [
24+
"{@link $text}"
25+
]
26+
}
27+
],
28+
"description": "Link"
29+
}
30+
}
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
{
2+
"mobxConstructor": {
3+
"definitions": [
4+
{
5+
"scope": {
6+
"langIds": [
7+
"typescript",
8+
"javascript",
9+
"typescriptreact",
10+
"javascriptreact"
11+
]
12+
},
13+
"body": [
14+
"constructor($parameters) {",
15+
"\tmakeAutoObservable(this);",
16+
"}"
17+
]
18+
}
19+
],
20+
"description": "Constructor using makeAutoObservable",
21+
"insertionScopeTypes": [
22+
"namedFunction"
23+
]
24+
},
25+
"constantDeclaration": {
26+
"definitions": [
27+
{
28+
"scope": {
29+
"langIds": [
30+
"typescript",
31+
"javascript",
32+
"typescriptreact",
33+
"javascriptreact"
34+
]
35+
},
36+
"body": [
37+
"const $name = ${value/^([^;]*);?$/$1/};"
38+
],
39+
"variables": {
40+
"name": {
41+
"formatter": "camelCase"
42+
}
43+
}
44+
}
45+
],
46+
"description": "Constant variable declaration",
47+
"insertionScopeTypes": [
48+
"statement"
49+
],
50+
"variables": {
51+
"value": {
52+
"wrapperScopeType": "statement"
53+
}
54+
}
55+
},
56+
"constantDeclarationWithType": {
57+
"definitions": [
58+
{
59+
"scope": {
60+
"langIds": [
61+
"typescript",
62+
"javascript",
63+
"typescriptreact",
64+
"javascriptreact"
65+
]
66+
},
67+
"body": [
68+
"const $name: $type = ${value/^([^;]*);?$/$1/};"
69+
],
70+
"variables": {
71+
"name": {
72+
"formatter": "camelCase"
73+
}
74+
}
75+
}
76+
],
77+
"description": "Constant variable declaration with type",
78+
"insertionScopeTypes": [
79+
"statement"
80+
],
81+
"variables": {
82+
"value": {
83+
"wrapperScopeType": "statement"
84+
}
85+
}
86+
},
87+
"letDeclaration": {
88+
"definitions": [
89+
{
90+
"scope": {
91+
"langIds": [
92+
"typescript",
93+
"javascript",
94+
"typescriptreact",
95+
"javascriptreact"
96+
]
97+
},
98+
"body": [
99+
"let $name = ${value/^([^;]*);?$/$1/};"
100+
],
101+
"variables": {
102+
"name": {
103+
"formatter": "camelCase"
104+
}
105+
}
106+
}
107+
],
108+
"description": "Let variable declaration",
109+
"insertionScopeTypes": [
110+
"statement"
111+
],
112+
"variables": {
113+
"value": {
114+
"wrapperScopeType": "statement"
115+
}
116+
}
117+
},
118+
"letDeclarationWithType": {
119+
"definitions": [
120+
{
121+
"scope": {
122+
"langIds": [
123+
"typescript",
124+
"javascript",
125+
"typescriptreact",
126+
"javascriptreact"
127+
]
128+
},
129+
"body": [
130+
"let $name: $type = ${value/^([^;]*);?$/$1/};"
131+
],
132+
"variables": {
133+
"name": {
134+
"formatter": "camelCase"
135+
}
136+
}
137+
}
138+
],
139+
"description": "Let variable declaration with type",
140+
"insertionScopeTypes": [
141+
"statement"
142+
],
143+
"variables": {
144+
"value": {
145+
"wrapperScopeType": "statement"
146+
}
147+
}
148+
}
149+
}

0 commit comments

Comments
 (0)