Title: Tab completion is unreliable in param blocks · Issue #15300 · PowerShell/PowerShell · GitHub
Open Graph Title: Tab completion is unreliable in param blocks · Issue #15300 · PowerShell/PowerShell
X Title: Tab completion is unreliable in param blocks · Issue #15300 · PowerShell/PowerShell
Description: A simple param block like this: Param ( $Param1 ) Will not offer tab completion for Parameters, Attributes, Members and possibly more things inside the param block. If you add a begin/process/end keyword like this: Param ( $Param1 ) begi...
Open Graph Description: A simple param block like this: Param ( $Param1 ) Will not offer tab completion for Parameters, Attributes, Members and possibly more things inside the param block. If you add a begin/process/end k...
X Description: A simple param block like this: Param ( $Param1 ) Will not offer tab completion for Parameters, Attributes, Members and possibly more things inside the param block. If you add a begin/process/end k...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/15300
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Tab completion is unreliable in param blocks","articleBody":"A simple param block like this:\r\n```powershell\r\nParam\r\n(\r\n $Param1\r\n)\r\n```\r\nWill not offer tab completion for Parameters, Attributes, Members and possibly more things inside the param block. \r\nIf you add a begin/process/end keyword like this:\r\n```powershell\r\nParam\r\n(\r\n $Param1\r\n)\r\nbegin\r\n```\r\nThe tab completion will work as you would expect. When I look at the ast the problem appears to be that the whole script is surrounded by an implicit end block unless you explicitly add a begin/process/end block and this causes the \"lastAst\" https://github.com/PowerShell/PowerShell/blob/master/src/System.Management.Automation/engine/CommandCompletion/CompletionAnalysis.cs#L395 to be a NamedBlockAst instead of an AttributeAst or whatever the various completions expect.\r\n\r\nAn easy fix that doesn't appear to break anything is to remove the NamedBlockAst from the list if it happens to be the last item in the \"RelatedAsts\" list but is there a better way? A safer alternative is to add more logic in every location where it causes issues today but do we really want more complexity in the completion code?\r\n## Steps to reproduce\r\n\r\n```powershell\r\nParam\r\n(\r\n $Param1=(Get-ChildItem -\u003cTab>)\r\n)\r\n```\r\n\r\n## Expected behavior\r\n\r\n```none\r\nParam\r\n(\r\n $Param1=(Get-ChildItem -Path)\r\n)\r\n```\r\n\r\n## Actual behavior\r\n\r\n```none\r\nParam\r\n(\r\n $Param1=(Get-ChildItem -)\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.2.0-preview.5\r\nPSEdition Core\r\nGitCommitId 7.2.0-preview.5\r\nOS Microsoft Windows 10.0.21359\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","author":{"url":"https://github.com/MartinGC94","@type":"Person","name":"MartinGC94"},"datePublished":"2021-04-23T19:29:16Z","url":"https://github.com/PowerShell/PowerShell/issues/15300"}
| 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 | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:62440ae1-083d-59d8-0412-c241b6ca6623 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9626:1A06A1:572F9D:7E3AC8:6AFD88C7 |
| html-safe-nonce | 00a8ff9808d432042f1c66e54e20fa0998692a4569b4f5384606261fc4e7173b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NjI2OjFBMDZBMTo1NzJGOUQ6N0UzQUM4OjZBRkQ4OEM3IiwidmlzaXRvcl9pZCI6IjY1MDg1NzExMzQwOTMyNjUwOTUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | c606473a1af2fd3a98c312de93a9ba776b513fb352c2825f577ac8e87228742a |
| hovercard-subject-tag | issue:866375491 |
| 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/_view_fragments/issues/show/PowerShell/PowerShell/15300/issue_layout |
| twitter:image | https://opengraph.githubassets.com/89ec0b0e5130790533f614495ff9bb9a3db66847e12bd97c81d1330b16c08426/PowerShell/PowerShell/issues/15300 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/89ec0b0e5130790533f614495ff9bb9a3db66847e12bd97c81d1330b16c08426/PowerShell/PowerShell/issues/15300 |
| og:image:alt | A simple param block like this: Param ( $Param1 ) Will not offer tab completion for Parameters, Attributes, Members and possibly more things inside the param block. If you add a begin/process/end k... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | MartinGC94 |
| hostname | github.com |
| expected-hostname | github.com |
| None | bc86424ef34a73b386237872800e922d149d65ba907f63d6f150a2dcb8433bea |
| turbo-cache-control | no-preview |
| 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 | 927a6c5ab1c32b38830f1b9d3050c0b9e9aa92e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width