SlickEdit Community

SlickEdit Product Discussion => SlickEdit® => Topic started by: jporkkahtc on June 04, 2021, 10:33:45 pm

Title: Powershell language problems.
Post by: jporkkahtc on June 04, 2021, 10:33:45 pm
Powershell doesn't support "Class"

Powershell file extensions should include "psd1" and "ps1xml"

Powershell coloring corrections
    See the attached .ps1 file demonstrating where Slick gets string and comment coloring wrong.
    It is also missing some keywords - more than what I have added.
    Also attached are my powershell color configuration.

Title: Re: Powershell language problems.
Post by: Clark on June 06, 2021, 11:55:13 pm
At the moment, we haven't added color coding for all special sequences in strings (escapes, simple embedded variables, etc.) . At some point, we should do this.

The problem with "$things:#OK" is more of a limitation. #whatever sadly is not always a comment. For example, "echo abc#whatever".  #whever is NOT a comment (what a horrible design!). There is a specific regex which bypasses the comment coloring and it does not correctly cover all cases ("(#<=[^ \t,;|&,.:(){}\]><])\#"). You can remove it but it will only fix the first case and break my echo example. We might be able to tweak this regex to handle this case but for now we will leave this alone.

As for the ${...} that isn't working, I've attached a fix for you.  I suspect you modified the double quoted string property in an older release of SlickEdit which did not yet have the ${...} support in it. This is a limitation of the config system. It will likely never be able to merge in this type of new change. Once you modify a property, you no longer get any changes (enhancements), made to that property in the future. We gave up trying to support merging of sub-properties within a property. It just too complicated.
Title: Re: Powershell language problems.
Post by: jporkkahtc on June 07, 2021, 07:12:55 pm
The comment thing is messed up!
Interesting that the Powershell command prompt understands this, but VSCode doesn't.

Thanks for the fix.
Title: Re: Powershell language problems.
Post by: jporkkahtc on June 07, 2021, 07:24:07 pm
WRT the config system merging: Understandable.
But, it would be great to be able to see the difference between my configuration and the default configuration!
Perhaps even a right-click menu "Revert to default"

Export seems to do some diffing and only exports things that have changed?
But, this still doesn't tell me what the default is, just that it is different.
Title: Re: Powershell language problems.
Post by: Clark on June 07, 2021, 08:41:11 pm
The color coding dialog does have a Reset button but it's for the entire profile (every property). There's no reset for individual properties.

Showing differences would be interesting. This would essentially be a "Diff" button which diffs the two profiles. Definitely very doable.

For now, you can display the builtin default profile by opening the file:

e plugin://com_slickedit.base/colorcoding_profiles/colorcoding_profiles.PowerShell.cfg.xml

You can also use the Open tool window to open the file. The Windows Open dialog just won't work at all even if you specify the .zip file which it is contained in.

Looking at the definitions in the default color coding profile should help you A LOT!. Just find the definition of the property giving you problems. In this case 'string,"'.

I'm not surprised export only exports the differences. Much older versions of SlickEdit would always output the entire config which meant that users never got updates made by SlickEdit after import.
Title: Re: Powershell language problems.
Post by: jporkkahtc on June 07, 2021, 09:33:11 pm
I can also just create a new profile - instead of modifying "PowerShell", I copy it to "PowerShellJoe", then modify that. Now I can toggle back and forth to see the default and compare to my settings.

WRT Diff: Doesn't have to be a full difference like DiffZilla (or did you mean diffing the *.cfg.xml files?)
I was thinking of something more integrated with the options dialog.

Put a "*", or some highlight on each thing in the tree view on the left that has differences from the default. Bonus points if you also highlight individual line items on the right.

I many cases the default value could be displayed in a box like the help text (but it can't be static since the defaults depend on the Emulation).

Showing the default values for a page like: Tools > Options > Appearance > General
Seems relatively easy, while pages like: Tools > Options > Appearance > Colors
would be a lot harder.
Displaying differences for: Tools > Options > Languages > Scripting Languages > PowerShell > Color Coding
I have no idea - other than adding a "*" to the profile name to show that it is modified, displaying differences (or even the default values) in some useful way seems really hard.
Title: Re: Powershell language problems.
Post by: Clark on June 07, 2021, 10:24:38 pm
With the new config system, we try to implement things in reusable way. Otherwise, we end up reinventing the wheel for every dialog we implement. This was the reason we redesigned the configuration system in SlickEdit. There was too much code that was duplicated because there was no way to reuse any code.

Diffing two profiles would be a general purpose way for the user to see their differences but it is a bit low level. We should be able to determine which properties are modified. It's just a matter of coming up with a place to indicate it. In regard to the issue you ran into, just knowing you changed a property isn't enough. You need to see the actual differences. Doing that in the dialog itself is very hard and not general purpose at all.
Title: Re: Powershell language problems.
Post by: jporkkahtc on June 08, 2021, 09:22:02 pm
Clark you probably already realize this, but Powershell also allows the fancy quotes
Code: [Select]

So for strings, the start/end delimiters should be [“”„"].
"Two Consecutive quotes represent one" should also be [“”„"], but it isn't allowed.

Of course, it also allows alternative dash characters.
Looks like you can use any of 4 characters for dash (0x22, 0x2013,0x2014,0x2015) for things like "5 - 6", or "$a -= 3", or "$true -and $false" and they are interchangeable. When used as part of an identifier though, each is unique and not interchangeable. (Operators like '-and' are not identifiers, they are defined as "dash op")

Who designed this language?
Title: Re: Powershell language problems.
Post by: Clark on June 08, 2021, 11:09:10 pm
Very helpful. Thanks. I did not know. We have not written a full parser for PowerShell so there hasn't been a need to learn every detail. When we do that we run the parser on a lot of test code to see if the parser understands all syntax. In the case of PowerShell, we primarily just added color coding and smart editing which doesn't need as much detail. We didn't find these additional string pairs. I will add a hot fix for these strings. As for the invalid doubles char, this can be worked around by adding a subitem and setting the start to the two consecutive Unicode characters. It would be nice though if the doubles char could any unicode character (definitely doable--maybe v26).