Script Formatting Introduces Coding Error

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 1 year and 6 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
User avatar
gareth.jacobs
Posts: 34
Last visit: Wed Jan 24, 2024 7:43 pm

Script Formatting Introduces Coding Error

Post by gareth.jacobs »

Product: PowerShell Studio 2022 (64 Bit)
Build: v5.8.209
OS: Windows 10 Enterprise (64 Bit)
Build: v10.0.19043.0

Formatting introduces a coding error in a specific circumstance.

Here is the not particularly well formatted, but working code portion prior to formatting:
  1. if ($FileOpenTrue) {
  2.                 Remove-Item $FileOpenTrue.FullName -ErrorAction SilentlyContinue;
  3.                 if (!$?) # Deletion of open handle file failed - likely due to multiple dsamain instances running
  4.                     {
  5.                         Write-Host "[X] Unable to remove the open handle file:`n$(($Error[0]).exception.Message)" -ForegroundColor DarkYellow
  6.                         Write-Host "[X] Make sure you don't have other dsamain instances running from multiple runs of the command.`ne.g. Type " -ForegroundColor Yellow -NoNewline;
  7.                         Write-Host -NoNewline "Get-Process dsamain" -ForegroundColor Cyan; Write-Host ", and see results. Can remove them with " -NoNewline -ForegroundColor Yellow;
  8.                         Write-Host -NoNewline "Get-Process dsamain | Stop-Process -Force`n" -ForegroundColor Cyan;
  9.                     }
  10.             }
After formatting, a coding error was introduced when the "{" character was turned into a comment after being pulled back to the end of the comment line, as shown:
  1. if ($FileOpenTrue) {
  2.             Remove-Item $FileOpenTrue.FullName -ErrorAction SilentlyContinue;
  3.             if (!$?) # Deletion of open handle file failed - likely due to multiple dsamain instances running {
  4.                 Write-Host "[X] Unable to remove the open handle file:`n$(($Error[0]).exception.Message)" -ForegroundColor DarkYellow
  5.                 Write-Host "[X] Make sure you don't have other dsamain instances running from multiple runs of the command.`ne.g. Type " -ForegroundColor Yellow -NoNewline;
  6.                 Write-Host -NoNewline "Get-Process dsamain" -ForegroundColor Cyan; Write-Host ", and see results. Can remove them with " -NoNewline -ForegroundColor Yellow;
  7.                 Write-Host -NoNewline "Get-Process dsamain | Stop-Process -Force`n" -ForegroundColor Cyan;
  8.             }
  9.         }
User avatar
brittneyr
Site Admin
Posts: 1649
Last visit: Mon Mar 18, 2024 1:47 pm
Answers: 38
Been upvoted: 30 times

Re: Script Formatting Introduces Coding Error

Post by brittneyr »

Can you please provide a screenshot of your Formatting settings in options:
SPS_OptionsFormatting.png
SPS_OptionsFormatting.png (30.74 KiB) Viewed 1804 times
Brittney
SAPIEN Technologies, Inc.
User avatar
gareth.jacobs
Posts: 34
Last visit: Wed Jan 24, 2024 7:43 pm

Re: Script Formatting Introduces Coding Error

Post by gareth.jacobs »

Settings as requested
editor_settings.jpg
editor_settings.jpg (84.23 KiB) Viewed 1652 times
User avatar
brittneyr
Site Admin
Posts: 1649
Last visit: Mon Mar 18, 2024 1:47 pm
Answers: 38
Been upvoted: 30 times

Re: Script Formatting Introduces Coding Error

Post by brittneyr »

Thank you for reporting. I've been able to reproduce this and have filed a bug report with the development team. I'll post here when I have any new information.
Brittney
SAPIEN Technologies, Inc.
User avatar
brittneyr
Site Admin
Posts: 1649
Last visit: Mon Mar 18, 2024 1:47 pm
Answers: 38
Been upvoted: 30 times

Re: Script Formatting Introduces Coding Error

Post by brittneyr »

Please build 5.8.210 and let me know if you are still experiencing this issue.
Brittney
SAPIEN Technologies, Inc.
User avatar
gareth.jacobs
Posts: 34
Last visit: Wed Jan 24, 2024 7:43 pm

Re: Script Formatting Introduces Coding Error

Post by gareth.jacobs »

Tested on updated version - problem fixed.

Thanks
g
This topic is 1 year and 6 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.