From 0c5f2f8c23add289b3909c352f0c28213ac38537 Mon Sep 17 00:00:00 2001 From: Cydroz <46122593+Cydroz@users.noreply.github.com> Date: Mon, 6 Jan 2025 23:48:04 +1100 Subject: [PATCH] Add tab step to customise increment varname --- snippets/PowerShell.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/snippets/PowerShell.json b/snippets/PowerShell.json index 5ae01e3082..d0a94ba30b 100644 --- a/snippets/PowerShell.json +++ b/snippets/PowerShell.json @@ -166,16 +166,16 @@ "description": "Insert a foreach loop with Write-Progress initialized", "body": [ "\\$total = \\$${1:array}.count", - "\\$i = 1", - "\\$progPercent = \"{0:n2}\" -f ([math]::round(\\$i/\\$total,4) * 100)", - "Write-Progress -Activity \"${3:activityName}\" -Status \"\\$i of \\$total - \\$progPercent% Complete:\" -PercentComplete \\$progPercent", + "\\$${4:i} = 1", + "\\$progPercent = \"{0:n2}\" -f ([math]::round(\\$${4:i}/\\$total,4) * 100)", + "Write-Progress -Activity \"${3:activityName}\" -Status \"\\$${4:i} of \\$total - \\$progPercent% Complete:\" -PercentComplete \\$progPercent", "foreach ($${2:item} in $${1:array}) {", - " \\$progPercent = \"{0:n2}\" -f ([math]::round(\\$i/\\$total,4) * 100)", - " Write-Progress -Activity \"${3:activityName}\" -Status \"\\$i of \\$total - \\$progPercent% Complete:\" -PercentComplete \\$progPercent", + " \\$progPercent = \"{0:n2}\" -f ([math]::round(\\$${4:i}/\\$total,4) * 100)", + " Write-Progress -Activity \"${3:activityName}\" -Status \"\\$${4:i} of \\$total - \\$progPercent% Complete:\" -PercentComplete \\$progPercent", " # Insert Code Here", " ${0}", " ", - " \\$i++", + " \\$${4:i}++", "}", "" ]