Title: ValidateSet/Register-ArgumentCompleter/Enum completions does not work correctly on Arrays · Issue #13757 · PowerShell/PowerShell · GitHub
Open Graph Title: ValidateSet/Register-ArgumentCompleter/Enum completions does not work correctly on Arrays · Issue #13757 · PowerShell/PowerShell
X Title: ValidateSet/Register-ArgumentCompleter/Enum completions does not work correctly on Arrays · Issue #13757 · PowerShell/PowerShell
Description: PowerShell for every system! Contribute to PowerShell/PowerShell development by creating an account on GitHub.
Open Graph Description: PowerShell for every system! Contribute to PowerShell/PowerShell development by creating an account on GitHub.
X Description: PowerShell for every system! Contribute to PowerShell/PowerShell development by creating an account on GitHub.
Opengraph URL: https://github.com/PowerShell/PowerShell
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ValidateSet/Register-ArgumentCompleter/Enum completions does not work correctly on Arrays","articleBody":"\u003c!--\r\n\r\nFor Windows PowerShell 5.1 issues, suggestions, or feature requests please use the following link instead:\r\nWindows PowerShell [UserVoice](https://windowsserver.uservoice.com/forums/301869-powershell)\r\n\r\nThis repository is **ONLY** for PowerShell Core 6 and PowerShell 7+ issues.\r\n\r\n- Make sure you are able to repro it on the [latest released version](https://github.com/PowerShell/PowerShell/releases)\r\n- Search the existing issues.\r\n- Refer to the [FAQ](https://github.com/PowerShell/PowerShell/blob/master/docs/FAQ.md).\r\n- Refer to the [known issues](https://docs.microsoft.com/powershell/scripting/whats-new/known-issues-ps6).\r\n\r\n-->\r\n\r\n## Steps to reproduce\r\n\r\n```powershell\r\nfunction New-Function {\r\n [cmdletBinding()]\r\n param(\r\n [validateSet('New', 'Old', 'Other')][string[]] $Test1,\r\n [validateSet('New', 'Old', 'Other')][string[]] $Test2\r\n )\r\n}\r\nNew-Function -Test1 New -Test2 New\r\nNew-Function -Test1 New, Old -Test2 New\r\nNew-Function -Test1 New, Old -Test2 New\r\n```\r\n\r\nPaste in VSCode. Try to autocomplete Test2 parameter on line 8 (first instance in the script). It will work for 1st element of array, but if you try adding 2nd or 3rd element autocomplete fails. \r\n\r\nIt works correctly if you start from top to bottom as in \r\n\r\n```powershell\r\nfunction New-Function {\r\n [cmdletBinding()]\r\n param(\r\n [validateSet('New', 'Old', 'Other')][string[]] $Test1,\r\n [validateSet('New', 'Old', 'Other')][string[]] $Test2\r\n )\r\n}\r\nNew-Function -Test1 New -Test2 New\r\n```\r\nIt will work on line 8\r\n\r\n```powershell\r\nfunction New-Function {\r\n [cmdletBinding()]\r\n param(\r\n [validateSet('New', 'Old', 'Other')][string[]] $Test1,\r\n [validateSet('New', 'Old', 'Other')][string[]] $Test2\r\n )\r\n}\r\nNew-Function -Test1 New -Test2 New\r\nNew-Function -Test1 New, Old -Test2 New\r\nNew-Function -Test1 New, Old -Test2 New\r\n```\r\n\r\nIt will work on line 10 but fails for lines 8 and 9. \r\n\r\n\r\n\r\nOriginally reported in VSCode PowerShell extension where more discussion is present: https://github.com/PowerShell/vscode-powershell/issues/2982\r\n\r\n## Expected behavior\r\n\r\nAutocomplete working on arrays in any order. On first line, last line, middle line. \r\n\r\n## Actual behavior\r\n\r\n```none\r\n\r\n```\r\n\r\n## Environment data\r\n\r\n\u003c!-- provide the output of $PSVersionTable -->\r\n\r\n```none\r\nName Value\r\n---- -----\r\nPSVersion 7.1.0-rc.1\r\nPSEdition Core\r\nGitCommitId 7.1.0-rc.1\r\nOS Microsoft Windows 10.0.19042\r\nPlatform Win32NT\r\nPSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}\r\nPSRemotingProtocolVersion 2.3\r\nSerializationVersion 1.1.0.1\r\nWSManStackVersion 3.0\r\n\r\n```\r\n","author":{"url":"https://github.com/PrzemyslawKlys","@type":"Person","name":"PrzemyslawKlys"},"datePublished":"2020-10-07T19:44:37Z","url":"https://github.com/PowerShell/PowerShell/issues/13757"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/issues/:id(.:format) |
| route-controller | issues |
| route-action | show |
| fetch-nonce | v2:a971055f-5fe2-f0ac-b759-b1a150f96b78 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 805E:178F0E:BD2C08:10F9006:6AFDAA03 |
| html-safe-nonce | ebb79ed20c65cfa19814839404443bfd55cf331654414bea8b4b43e60fdee071 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MDVFOjE3OEYwRTpCRDJDMDg6MTBGOTAwNjo2QUZEQUEwMyIsInZpc2l0b3JfaWQiOiI3NzEwMDgzNzU4NzY4NTYzMjQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 094beca6b50d0afe245ef30072a73226f062fb8940518dc038f34e29206b2e37 |
| hovercard-subject-tag | repository:49609581 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/PowerShell/PowerShell/issues/13757 |
| twitter:image | https://repository-images.githubusercontent.com/49609581/aad0ad80-cdec-11ea-8248-a37bc0571bfd |
| twitter:card | summary_large_image |
| og:image | https://repository-images.githubusercontent.com/49609581/aad0ad80-cdec-11ea-8248-a37bc0571bfd |
| og:image:alt | PowerShell for every system! Contribute to PowerShell/PowerShell development by creating an account on GitHub. |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | bc86424ef34a73b386237872800e922d149d65ba907f63d6f150a2dcb8433bea |
| turbo-cache-control | no-cache |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 0ddf53eb35c87f1f8df13dbf75c3bdadbfc6e969 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width