SeeminglyScience / EditorServicesCommandSuite

Collection of editor commands for use in PowerShell Editor Services.
Other
151 stars 13 forks source link

ConvertTo-SplatExpression : the new text is not correctly inserted #26

Closed LaurentDardenne closed 5 years ago

LaurentDardenne commented 6 years ago

With the following code :

         if ($isLiteral)
         { Set-Content -Value $TypeData -LiteralPath $FileName -Encoding UTF8 -Confirm:$false}
         else
         { Set-Content -Value $TypeData -Path $FileName -Encoding UTF8 -Confirm:$false}

Call ConvertTo-SplatExpression by F1 do not work correctly :

         if ($isLiteral)
         $setContentSplat = @{
            Value = $TypeData
            LiteralPath = $FileName
         }
        { Set-Content @setContentSplat}
         else
        { Set-Content -Value $TypeData -Path $FileName -Encoding UTF8 -Confirm:$false}

No error with this text :

         if ($isLiteral)
         { 
           Set-Content -Value $TypeData -LiteralPath $FileName -Encoding UTF8 -Confirm:$false
         }
         else
        { Set-Content -Value $TypeData -Path $FileName -Encoding UTF8 -Confirm:$false}
SeeminglyScience commented 6 years ago

Thanks for reporting this! I see what I did wrong :)

I'm in the middle of rewriting a lot of this in C#, I've confirmed the new code doesn't have the same issue. I'll leave this open until that release.