"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

@@ -133,7 +133,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"
@@ -142,7 +142,7 @@
"prefix": "foreach =>",
"body": [
"${1:array}.forEach(${2:element} => {",
"\t$0",
"\t$TM_SELECTED_TEXT$0",
"});"
],
"description": "For-Each Loop using =>"
@@ -153,7 +153,7 @@
"for (const ${1:key} in ${2:object}) {",
"\tif (Object.prototype.hasOwnProperty.call(${2:object}, ${1:key})) {",
"\t\tconst ${3:element} = ${2:object}[${1:key}];",
"\t\t$0",
"\t\t$TM_SELECTED_TEXT$0",
"\t}",
"}"
],
@@ -163,7 +163,7 @@
"prefix": "forof",
"body": [
"for (const ${1:iterator} of ${2:object}) {",
"\t$0",
"\t$TM_SELECTED_TEXT$0",
"}"
],
"description": "For-Of Loop"
@@ -172,7 +172,7 @@
"prefix": "forawaitof",
"body": [
"for await (const ${1:iterator} of ${2:object}) {",
"\t$0",
"\t$TM_SELECTED_TEXT$0",
"}"
],
"description": "For-Await-Of Loop"
@@ -181,7 +181,7 @@
"prefix": "function",
"body": [
"function ${1:name}(${2:params}:${3:type}) {",
"\t$0",
"\t$TM_SELECTED_TEXT$0",
"}"
],
"description": "Function Statement"
@@ -190,7 +190,7 @@
"prefix": "if",
"body": [
"if (${1:condition}) {",
"\t$0",
"\t$TM_SELECTED_TEXT$0",
"}"
],
"description": "If Statement"
@@ -199,7 +199,7 @@
"prefix": "ifelse",
"body": [
"if (${1:condition}) {",
"\t$0",
"\t$TM_SELECTED_TEXT$0",
"} else {",
"\t",
"}"
@@ -231,7 +231,7 @@
"prefix": "while",
"body": [
"while (${1:condition}) {",
"\t$0",
"\t$TM_SELECTED_TEXT$0",
"}"
],
"description": "While Statement"
@@ -240,7 +240,7 @@
"prefix": "dowhile",
"body": [
"do {",
"\t$0",
"\t$TM_SELECTED_TEXT$0",
"} while (${1:condition});"
],
"description": "Do-While Statement"
@@ -249,7 +249,7 @@
"prefix": "trycatch",
"body": [
"try {",
"\t$0",
"\t$TM_SELECTED_TEXT$0",
"} catch (${1:error}) {",
"\t",
"}"
@@ -260,7 +260,7 @@
"prefix": "settimeout",
"body": [
"setTimeout(() => {",
"\t$0",
"\t$TM_SELECTED_TEXT$0",
"}, ${1:timeout});"
],
"description": "Set Timeout Function"
@@ -283,7 +283,7 @@
"prefix": "newpromise",
"body": [
"new Promise<${1:void}>((resolve, reject) => {",
"\t$0",
"\t$TM_SELECTED_TEXT$0",
"})"
],
"description": "Create a new Promise"
@@ -292,7 +292,7 @@
"prefix": "async function",
"body": [
"async function ${1:name}(${2:params}:${3:type}) {",
"\t$0",
"\t$TM_SELECTED_TEXT$0",
"}"
],
"description": "Async Function Statement"
@@ -301,7 +301,7 @@
"prefix": "async arrow function",
"body": [
"async (${1:params}:${2:type}) => {",
"\t$0",
"\t$TM_SELECTED_TEXT$0",
"}"
],
"description": "Async Function Expression"