-
Notifications
You must be signed in to change notification settings - Fork 292
Closed
Description
This previously formatted fine, but now its broken.
VS Code 1.33.1
PSSA 1.18.0
$scriptDefinition = @'
if ($ifmResxContent.root.data.name -match $srecBlockNameMatch) {
$resxFile.FullName # indicate the file we're processing
# find each data block we believe we can process because it possesses an SREC file believed to be stored in Flash
foreach ($datablock in ($ifmResxContent.root.data | Where-Object name -Match $srecBlockNameMatch)) {
$orgDataLength = $datablock.value.Length
# convert reduced result back to Base64String
$datablock.value = ([Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes(
# convert from Base64String
[Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($datablock.value)
# remove effectively empty S3, S2, or S1 DATA records
) -replace 'S(?:(?:3.{4})|(?:2..)|(?:1)).{6}(?:FF)+..\r*\n')
# take the new Base64String and break it into 80 character lines formatted as assumed for the RESX file
) -replace '.{1,80}', "`n `$&") + "`n"
"...Reduced block '$($datablock.name)' by $($orgDataLength - $datablock.value.Length) bytes."
}
# put the file back out with XMLWriter, as PowerShell seems to lack integral XML object output support.
$xmlWriter = [Xml.XmlWriter]::Create("$($resxFile.DirectoryName)\$($resxFile.BaseName) Reduced.resx", $xmlSettings)
try {
$ifmResxContent.Save($xmlWriter)
}
finally {
$xmlWriter.Dispose()
}
# generate the hash file for the rebuilt RESX file
Set-Content "$($resxFile.DirectoryName)\$($resxFile.BaseName) Reduced.md5" (Get-FileHash "$($resxFile.DirectoryName)\$($resxFile.BaseName) Reduced.resx" -Algorithm MD5).hash.ToLowerInvariant()
}
'@
Invoke-Formatter -ScriptDefinition $scriptDefinition
if I format just the foreach block by itself in Invoke-Formatter, its fine, but in VS Code the second line fails to indent, throwing everything else after it off, or if I include the prior IF statement, it fails, same thing.
if ($ifmResxContent.root.data.name -match $srecBlockNameMatch) {
$resxFile.FullName # indicate the file we're processing
# find each data block we believe we can process because it possesses an SREC file believed to be stored in Flash
foreach ($datablock in ($ifmResxContent.root.data | Where-Object name -Match $srecBlockNameMatch)) {
$orgDataLength = $datablock.value.Length
# convert reduced result back to Base64String
$datablock.value = ([Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes(
# convert from Base64String
[Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($datablock.value)
# remove effectively empty S3, S2, or S1 DATA records
) -replace 'S(?:(?:3.{4})|(?:2..)|(?:1)).{6}(?:FF)+..\r*\n')
# take the new Base64String and break it into 80 character lines formatted as assumed for the RESX file
) -replace '.{1,80}', "`n `$&") + "`n"
"...Reduced block '$($datablock.name)' by $($orgDataLength - $datablock.value.Length) bytes."
}
# put the file back out with XMLWriter, as PowerShell seems to lack integral XML object output support.
$xmlWriter = [Xml.XmlWriter]::Create("$($resxFile.DirectoryName)\$($resxFile.BaseName) Reduced.resx", $xmlSettings)
try {
$ifmResxContent.Save($xmlWriter)
}
finally {
$xmlWriter.Dispose()
}
# generate the hash file for the rebuilt RESX file
Set-Content "$($resxFile.DirectoryName)\$($resxFile.BaseName) Reduced.md5" (Get-FileHash "$($resxFile.DirectoryName)\$($resxFile.BaseName) Reduced.resx" -Algorithm MD5).hash.ToLowerInvariant()
}
It has to do with pipe in the argument of the foreach statement. The pipe is IN the value argument, and the argument closes before the end of the line, so no indenting should apply to this pipe instance. If I change the indent setting for pipes back to 'none', it formats correct. However, I prefer continued lines to be indented (and not just when continued by pipe).
Metadata
Metadata
Assignees
Labels
No labels