Syntax Highlighting following modulus operator

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 7 years 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
OldLost
Posts: 55
Last visit: Wed Feb 21, 2018 8:00 am

Syntax Highlighting following modulus operator

Post by OldLost »

PowerShell Studio 2016 v5.2.127 x64
Windows Server 2012 R2 64bit

When using the modulus operator syntax highlighting appears messed up:
8-16-2016 2-34-23 PM.jpg
8-16-2016 2-34-23 PM.jpg (56.98 KiB) Viewed 3828 times
FYI, SaveColor is a valid parameter to the New-HeaderCell function and is highlighted correctly when the modulus operator is not used.
DevinL
Posts: 1098
Last visit: Tue Jun 06, 2017 9:15 am

Re: Syntax Highlighting following modulus operator

Post by DevinL »

I'm currently unable to reproduce this, could you provide me with some more information regarding your script? I typed out the exact same thing you have there and even created a faux New-HeaderCell function just to verify.

A few things that would be helpful:
  • Have you made any custom color settings in Options -> Editor -> Font and Color..?
  • What exactly does the New-HeaderCell function do? Can you provide the function itself?
  • Is this a .ps1 file or a .psf?
Here's a screenshot of my attempt to reproduce it:
Modulus_Syntax_Highlighting.png
Modulus_Syntax_Highlighting.png (22.92 KiB) Viewed 3818 times
DevinL
SAPIEN Technologies, Inc.
User avatar
OldLost
Posts: 55
Last visit: Wed Feb 21, 2018 8:00 am

Re: Syntax Highlighting following modulus operator

Post by OldLost »

Have you made any custom color settings in Options -> Editor -> Font and Color..?

Oh, indeed. Lots. Attached is my (slightly sanitized) settings xml file.

What exactly does the New-HeaderCell function do? Can you provide the function itself?

Sure. Nothing special. It returns a string of HTML.
  1. function New-HeaderCell {
  2.     [CmdletBinding(DefaultParameterSetName = 'SaveColor')] [OutputType([System.String])]
  3.     Param (
  4.         [Parameter(Mandatory, Position = 0)][string]$Text,
  5.         [Parameter(Position = 1, ParameterSetName = 'SaveColor')][string]$Color = '#024D89',
  6.         [int]$ColSpan = 0,
  7.         [int]$RowSpan = 0,
  8.         [Parameter(ParameterSetName = 'SaveColor')][Parameter(ParameterSetName = 'RandomColor')][string]$SaveColor,
  9.         [Parameter(ParameterSetName = 'UseColor')][string]$UseColor,
  10.         [Parameter(ParameterSetName = 'RandomColor')][switch]$RandomColor
  11.     )
  12.     switch ($PsCmdlet.ParameterSetName) {
  13.         'RandomColor'  { $Color = Get-RandomColor; if ($SaveColor) { $SavedColors[$SaveColor] = $Color; break } }
  14.         'SaveColor'  { if ($SaveColor) { $SavedColors[$SaveColor] = $Color; break } }
  15.         'UseColor'  {
  16.             $Color = $SavedColors[$UseColor]
  17.             if (!$Color) { $Color = '#024D89' }
  18.             break
  19.         }
  20.     }
  21.     $Out = '<th'
  22.     if ($ColSpan) {
  23.         $Out += ' colspan="{0}"' -f $ColSpan
  24.     }
  25.     if ($RowSpan) {
  26.         $Out += ' rowspan="{0}"' -f $RowSpan
  27.     }
  28.     # '{2} style="background-color:{1};color:white;text-align:center;vertical-align:bottom;">{0}</th>' -f $Text, $Color, $Out
  29.     '{2} style="background-color:{1};">{0}</th>' -f $Text, $Color, $Out
  30. }
Is this a .ps1 file or a .psf?

PS1
Attachments
PowerShellStudio.Settings.xml
(25.72 KiB) Downloaded 134 times
DevinL
Posts: 1098
Last visit: Tue Jun 06, 2017 9:15 am

Re: Syntax Highlighting following modulus operator

Post by DevinL »

Thank you for that, I'll look into this and get back to you when I have some more information.
DevinL
SAPIEN Technologies, Inc.
DevinL
Posts: 1098
Last visit: Tue Jun 06, 2017 9:15 am

Re: Syntax Highlighting following modulus operator

Post by DevinL »

Well I imported your PowerShell Studio settings, added in your New-HeaderCell function and still am not having much luck reproducing this. I say much luck because I did notice the closing bracket isn't colored properly so there's some progress.

Since you mentioned this is one ps1 is there anyway you can upload the ps1 and I can try to reproduce it with that? If you don't want the code to be public you're welcome to upload it to our support uploads section which is only accessible by us support staff: https://sapien.com/support/upload
DevinL
SAPIEN Technologies, Inc.
DevinL
Posts: 1098
Last visit: Tue Jun 06, 2017 9:15 am

Re: Syntax Highlighting following modulus operator

Post by DevinL »

It may have helped if I attached the screenshot of my results :lol:

Here's what I ended up with on my end:
Modulus_Syntax_Highlighting-2.png
Modulus_Syntax_Highlighting-2.png (63.75 KiB) Viewed 3793 times
DevinL
SAPIEN Technologies, Inc.
User avatar
OldLost
Posts: 55
Last visit: Wed Feb 21, 2018 8:00 am

Re: Syntax Highlighting following modulus operator

Post by OldLost »

Thanks. Yes, looking at your screenshot not only is the bracket miscolored but so is the operator itself as well as the number. Based on the color scheme and the fact it's an operator, the color of the % character should be red (it's yellow in the first instance and a brown in the second), and the 3 (at least in the first instance) is an off-white whereas it should be purple. I was able to duplicate your results in a new file.

While the original screenshot is from a PS1 file, many of the functions it uses are actually coming from a module. The New-HeaderCell function, for example, actually is part of a module. I also am having difficulties recreating the miscoloring of the SaveColor parameter name in another file, but it remains miscolored in the original file as the screenshot in the first post shows. I will upload both the PS1 file and the PSM file to the link you gave shortly.
User avatar
OldLost
Posts: 55
Last visit: Wed Feb 21, 2018 8:00 am

Re: Syntax Highlighting following modulus operator

Post by OldLost »

Looking at the screenshot in your first post a bit closer, you'll notice even there that the operator and the bracket are miscolored on line 5. It's a bit hard to tell without looking closely, but the operator appears to be blue and italicized, whereas it should be the same color as the other operators ("=" specifically, but it is a slightly different shade), and not italicized. (The number may be miscolored as well, but with that scheme it's hard to tell.) And the second instance of % on line 6 is white, which is not correct either according to your scheme.

Edit: looking at it closer, maybe it's not italicized after all. Not sure, but it does not look quite the same as the % in line 6 regardless.
Clipboard01.png
Clipboard01.png (11.56 KiB) Viewed 3781 times
DevinL
Posts: 1098
Last visit: Tue Jun 06, 2017 9:15 am

Re: Syntax Highlighting following modulus operator

Post by DevinL »

Thank you for the upload, I'll try and reproduce it on my end using your files and let you know.

In the meantime, I've alerted the developers to this issue and will post here if I hear anything back.
DevinL
SAPIEN Technologies, Inc.
DevinL
Posts: 1098
Last visit: Tue Jun 06, 2017 9:15 am

Re: Syntax Highlighting following modulus operator

Post by DevinL »

Quick update, I've managed to reproduce this on my end successfully with the file you provided and passed this on to the developers as well.

I see what you mean about the -SaveColor parameter changing colors in the original script and yet with a new file it doesn't appear to be the off color yellow. Either way, we'll get this sorted out as soon as we can and I'll give you an update here when we've got it fixed.
DevinL
SAPIEN Technologies, Inc.
This topic is 7 years 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.