"Surround with" in TS/JS snippets (#138565)

* Preserve selected text in snippets to provide "surround-with"-like functionality.

* Add the same "surround with"-like functionality to JS snippets.
This commit is contained in:
Daniel Rosenwasser
2021-12-06 18:01:09 -08:00
committed by GitHub
parent 974442023a
commit 4fb22d76cf
2 changed files with 27 additions and 27 deletions

View File

@@ -17,7 +17,7 @@
"body": [
"for (let ${1:index} = 0; ${1:index} < ${2:array}.length; ${1:index}++) {",
"\tconst ${3:element} = ${2:array}[${1:index}];",
"\t$0",
"\t$TM_SELECTED_TEXT$0",
"}"
],
"description": "For Loop"
@@ -26,7 +26,7 @@
"prefix": "foreach",
"body": [
"${1:array}.forEach(${2:element} => {",
"\t$0",
"\t$TM_SELECTED_TEXT$0",
"});"
],
"description": "For-Each Loop"
@@ -37,7 +37,7 @@
"for (const ${1:key} in ${2:object}) {",
"\tif (Object.hasOwnProperty.call(${2:object}, ${1:key})) {",
"\t\tconst ${3:element} = ${2:object}[${1:key}];",
"\t\t$0",
"\t\t$TM_SELECTED_TEXT$0",
"\t}",
"}"
],
@@ -47,7 +47,7 @@
"prefix": "forof",
"body": [
"for (const ${1:iterator} of ${2:object}) {",
"\t$0",
"\t$TM_SELECTED_TEXT$0",
"}"
],
"description": "For-Of Loop"
@@ -56,7 +56,7 @@
"prefix": "function",
"body": [
"function ${1:name}(${2:params}) {",
"\t$0",
"\t$TM_SELECTED_TEXT$0",
"}"
],
"description": "Function Statement"
@@ -65,7 +65,7 @@
"prefix": "if",
"body": [
"if (${1:condition}) {",
"\t$0",
"\t$TM_SELECTED_TEXT$0",
"}"
],
"description": "If Statement"
@@ -74,7 +74,7 @@
"prefix": "ifelse",
"body": [
"if (${1:condition}) {",
"\t$0",
"\t$TM_SELECTED_TEXT$0",
"} else {",
"\t",
"}"
@@ -106,7 +106,7 @@
"prefix": "while",
"body": [
"while (${1:condition}) {",
"\t$0",
"\t$TM_SELECTED_TEXT$0",
"}"
],
"description": "While Statement"
@@ -115,7 +115,7 @@
"prefix": "dowhile",
"body": [
"do {",
"\t$0",
"\t$TM_SELECTED_TEXT$0",
"} while (${1:condition});"
],
"description": "Do-While Statement"
@@ -124,7 +124,7 @@
"prefix": "trycatch",
"body": [
"try {",
"\t$0",
"\t$TM_SELECTED_TEXT$0",
"} catch (${1:error}) {",
"\t",
"}"
@@ -135,7 +135,7 @@
"prefix": "settimeout",
"body": [
"setTimeout(() => {",
"\t$0",
"\t$TM_SELECTED_TEXT$0",
"}, ${1:timeout});"
],
"description": "Set Timeout Function"
@@ -144,7 +144,7 @@
"prefix": "setinterval",
"body": [
"setInterval(() => {",
"\t$0",
"\t$TM_SELECTED_TEXT$0",
"}, ${1:interval});"
],
"description": "Set Interval Function"