question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Enable tab completion for variables that are of enum type

See original GitHub issue

Summary 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:closed
  • Created 4 years ago
  • Reactions:6
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
SteveL-MSFTcommented, Sep 28, 2019

I think string is definitely more user friendly.

2reactions
mklement0commented, Sep 27, 2019

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)

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found