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.

Parameter and argument completion broken

See original GitHub issue

Issue Type: Bug

When a function parameter uses a PS-defined enum as datatype, parameter and argument completion are broken on the editor pane where the function was defined (even though the syntax displays correctly). The issue is not present on other opened editor panes or the console.

Try this code:

enum Cities
{
  Hannover
  Redmond
  NewYork
}

function Test-It
{
  param
  (
    [Cities]
    $City
  )
  
  $PSBoundParameters
}

Expected result:

When entering “Test-It -” and pressing CTRL+SPACE, there should be completion for parameter -City, then completion for arguments.

Actual result:

On the same editor pane where the function is defined, regardless of whether the code was run or not, there is no completion for parameter or arguments. The parameter completion list does not even contain the parameter and lists only standard entries.

When the code was run, the completion works for console and other editor panes, but never for the editor pane that defines the function.

Suspected Trigger:

The problem occurs once a parameter is using a PS-defined enum. When changing the data type from [Cities] to any non-PS-enum type like [ConsoleColor], there is no issue and all works fine. (using PS7.0.0 and editorservices 2020.3.0)

Extension version: 2020.3.0 VS Code version: Code 1.42.1 OS version: Windows_NT x64 10.0.18363

System Info
Item Value
CPUs Intel® Core™ i7-1065G7 CPU @ 1.30GHz (8 x 1498)
GPU Status 2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
protected_video_decode: enabled
rasterization: enabled
skia_renderer: disabled_off
surface_control: disabled_off
surface_synchronization: enabled_on
video_decode: enabled
viz_display_compositor: enabled_on
viz_hit_test_surface_layer: disabled_off
webgl: enabled
webgl2: enabled
Load (avg) undefined
Memory (System) 31.77GB (20.84GB free)
Process Argv
Screen Reader no
VM 0%

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
TobiasPSPcommented, Mar 8, 2020

I moved the issue over to the powershell team: https://github.com/PowerShell/PowerShell/issues/12079

For VSCode this is definitely no issue. Thanks for looking into this Tyler! Your test approach using tabexpansion2 directly was very helpful.

1reaction
TobiasPSPcommented, Mar 8, 2020

No in fact with the attribute example, this first surfaced in the ISE. Don’t know why the trainees moved back to ISE in the latter case, it is definitely editor-agnostic.

It must be related to how PowerShell parses the code. There is a slight difference: with the enum example, this messes up parameter completion altogether. With the completer attribute, only the completion results are messed up.

Should I open a case in the PowerShell repo?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Argument Completion Attributes - powershell.one
Enable argument completion for your own function parameters and make them so much easier to use! Some lesser-known attributes can help you.
Read more >
How to fix IntelliJ IDEA method parameter auto-completion?
The alternative is to break the habit/need for it and use IntelliJ's Code Completion shortcuts: Ctrl + P to view possible parameters for...
Read more >
Tab completion doesn't work for arguments when command is ...
5(1)-release, tab completion fails for the version with the alias. Note that this is not a problem with completing the alias itself --...
Read more >
Dynamic Tab Completion with PowerShell ArgumentCompleters
Parameter value PowerShell tab completion allows you to tab through available values you can pass to PowerShell commands. PowerShell parameter ...
Read more >
About functions argument completion - PowerShell
Argument completers provide the possible values for a parameter. The available values are calculated at runtime when the user presses the Tab ...
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