Enable tab completion for variables that are of enum type
See original GitHub issueSummary of the new feature/enhancement
When setting preference variables like $ErrorActionPreference
, it would be great to help users discover allowed values by:
$ErrorActionPreference = <tab>
instead of trying to set it to something invalid and seeing the allowed values in the error message.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:6
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Using a Custom Enum To Get Tab-Completion on a ...
PowerShell has a data type called an enum, which is a way to set a variable for a number of predefined constants.
Read more >About tab expansion - PowerShell
Enumerated values are strings, so the value to be completed must start with a single or double-quote character. ... Tab completion also works...
Read more >IntelliSense in Visual Studio Code
The editor supports "tab completion" which inserts the best matching completion when pressing Tab. This works regardless of the suggest widget showing or...
Read more >Automatic completion | ReSharper Documentation
You can enable or disable auto-completion using the Enable Automatic ... ReSharper: Suggesting type-based variable names in code completion ...
Read more >Make Eclipse list (only) all enum entries on assignment of ...
In my C (not C++) project I'm using typedef enums and would like that Eclipse provides a list of all enum entries on...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think string is definitely more user friendly.
Good question, @SeeminglyScience.
I’m thinking that even
$ErrorActionPreference = <tab>
(no opening quote) should complete to a string (e.g,$ErrorActionPreference = 'Stop'
), for two reasons:Using types and static properties is an advanced technique, and strings are more concise and provide better symmetry with use in arguments (e.g.,
-ErrorAction Stop
), where use of the static property expression would be impractical (e.g.,-ErrorAction ([System.Management.Automation.ActionPreference]::Stop)
)With flag enumerations, a string value is easier to modify later (again with tab-completion support), especially when new flags are added (e.g.,
'Compiled'
->'Compiled, IgnoreCase'
vs.[System.Text.RegularExpressions.RegexOptions]::Compiled
->[System.Text.RegularExpressions.RegexOptions]::Compiled -bor [System.Text.RegularExpressions.RegexOptions]::IgnoreCase
)