[PSS 2016][Misdemeanor] Autocomplete and statements

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 SUBSCRIPTION NUMBERS, LICENSE 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.
User avatar
Bosparan
Posts: 282
Joined: Sun Mar 03, 2013 12:45 pm

[PSS 2016][Misdemeanor] Autocomplete and statements

Post by Bosparan » Thu Mar 17, 2016 1:52 am

PSS Version: 2016 5.2.117
OS Version: Windows 10 x64
WMF Version: 5.0

Impact: Serious Annoyance

Symptom:
Autocomplete and Primal Sense will mark and auto-insert a function as soon as you finish a recognized verb. This is in general benign, as I can keep typing to refine the proposed insert or select it in the primal sense window.
However, this does not work well when certain powershell statements have the same name as some verbs, or when an type accelerator has the same name as a legit verb.
Typically affected are:
- Begin-Statement
- Process-Statement (Process is not an officially sanctioned verb, but still finds frequent enough usage)
- End-Statement
- Switch-Statement
- Switch-Accelerator (System.Management.Automation.SwitchParameter)

Reproducibility:
1) Install any of the following modules:
- Azure
- PKI
- SQLPS
- HPOACmdlets (HP PowerShell Management Kit)
These include cmdlets using the verb "Switch"

2) Recreate PSS Cache
3) Type this in the console ("|" is the current cursor position)

Code: Select all

$foo = "bar"
switc|
4) Type another "h". Primal Sense should now propose a cmdlet with the Verb Switch, autocomplete will select it
5) Type space to continue a typical switch statement. Autocomplete will now insert the selected cmdlet

Notes on Solution:
An idea I had was to mark for autocomplete only once one adds [Verb] + [-]. In the example above, that would mean only provide autocomplete once the user types "Switch-", rather than how it is now already after "Switch". This would remove all collisions with statements and accelerators.

User avatar
DevinL
Site Admin
Posts: 1098
Joined: Mon Aug 17, 2015 2:25 pm

Re: [PSS 2016][Misdemeanor] Autocomplete and statements

Post by DevinL » Thu Mar 17, 2016 12:42 pm

I've passed this on to the team and will let you know when I have some more information.

In the meantime, you can check the Autocomplete on exact match only option and it should stop this from happening.
Auto_Complete.png
Auto_Complete.png (20.36 KiB) Viewed 1371 times
DevinL
SAPIEN Technologies, Inc.

User avatar
Bosparan
Posts: 282
Joined: Sun Mar 03, 2013 12:45 pm

Re: [PSS 2016][Misdemeanor] Autocomplete and statements

Post by Bosparan » Fri Mar 18, 2016 4:00 am

Hi Devin,

thanks, and I hope something will come along, as it's rather troublesome. I'm aware of the workaround, but it's the greater evil, considering how autocomplete is a productivity increase most of the times (with above mentioned exception). If we disable it, we'll simply be irked when we don't get it but would like to. We're so used to autocomplete by now, that disabling it would just create a low of input errors where force of habit causes errors.

Btw, another very notable (and omnipresent) case of this issue is foreach vs. ForEach-Object.

Cheers

User avatar
davidc
Posts: 5913
Joined: Thu Aug 18, 2011 4:56 am

Re: [PSS 2016][Misdemeanor] Autocomplete and statements

Post by davidc » Tue Mar 22, 2016 10:08 am

You could try unchecking the "Enable word completion while typing" feature in Options->PrimalSense.

This will prevent the PrimalSense list from popping up after typing text that is longer than 3 characters.

Note: Pressing TAB will always auto-complete the current selection even when the "Autocomplete on exact match only" is checked.

David
David
SAPIEN Technologies, Inc.

User avatar
Bosparan
Posts: 282
Joined: Sun Mar 03, 2013 12:45 pm

Re: [PSS 2016][Misdemeanor] Autocomplete and statements

Post by Bosparan » Wed Mar 23, 2016 2:25 am

Hi David,

yes, disabling "Enable word completion while typing" would be a workaround around this. But - same as "Autocomplete on exact match only" the productivity loss would be worse.
Good to know I can force completion with tab, though that's not how our usage generally works (Which means, that while the latter option and "Tab" would be a fairly functional workaround, it would require more changes in habit than cancelling the primal sense with "ESC").

In the end we will go on with ESCaping Primal Sense (and cursing whenever we forget), but a fundamental fix will be appreciated :)

Thank you for the suggested workarounds,
Bosparan