René's URL Explorer Experiment


Title: Preventing fallback to default tab-completion behavior works inconsistently between Register-ArgumentCompleter and the [ArgumentCompleter] attribute with script blocks · Issue #19628 · PowerShell/PowerShell · GitHub

Open Graph Title: Preventing fallback to default tab-completion behavior works inconsistently between Register-ArgumentCompleter and the [ArgumentCompleter] attribute with script blocks · Issue #19628 · PowerShell/PowerShell

X Title: Preventing fallback to default tab-completion behavior works inconsistently between Register-ArgumentCompleter and the [ArgumentCompleter] attribute with script blocks · Issue #19628 · PowerShell/PowerShell

Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerShell 5.1 and PowerShell. Steps to reprodu...

Open Graph Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh...

X Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh...

Opengraph URL: https://github.com/PowerShell/PowerShell/issues/19628

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Preventing fallback to default tab-completion behavior works inconsistently between Register-ArgumentCompleter and the [ArgumentCompleter] attribute with script blocks","articleBody":"### Prerequisites\r\n\r\n- [X] Write a descriptive title.\r\n- [X] Make sure you are able to repro it on the [latest released version](https://github.com/PowerShell/PowerShell/releases)\r\n- [X] Search the existing issues.\r\n- [X] Refer to the [FAQ](https://github.com/PowerShell/PowerShell/blob/master/docs/FAQ.md).\r\n- [X] Refer to [Differences between Windows PowerShell 5.1 and PowerShell](https://docs.microsoft.com/powershell/scripting/whats-new/differences-from-windows-powershell).\r\n\r\n### Steps to reproduce\r\n\r\nBy default, when a script block used with `Register-CommandCompleter` or `[ArgumentCompleter]` produces _no output_, PowerShell falls back to default tab-completion (file and directory names).\r\n\r\nThis is usually undesired, and can be prevented by returning `$null` instead, but only from a script block used with `Register-CommandCompleter`, not also with the  `[ArgumentCompleter]`  attribute.\r\n\r\n* That `$null` works at all seems to be an _accident_, as it seems that it causes an _exception_ in `TabExpansion2` that is swallowed in interactive use, but effectively prevents the fallback.\r\n\r\n  * Still, having the ability to suppress fallback to default completion is important, and it should also be available for script-block-based  `[ArgumentCompleter]`  attributes.\r\n\r\n* By contrast, when using the  `[ArgumentCompleter]`  attribute with a class that implements `IArgumentCompleter`, fallback suppression _is_ possible, though the behavior is conceptually _reversed_:\r\n  * Returning an _empty enumerable_ effectively prevents fallback.\r\n  * Returning `$null` functions as an _opt-in_ to fallback behavior.\r\n  \r\nI think we need an officially supported - and documented - way to suppress fallback to the default behavior.\r\n\r\n```powershell\r\n# Register an argument completer that uses $null to suppress fallback to\r\n# default tab-completion.\r\nRegister-ArgumentCompleter -CommandName Foo1 -ParameterName Bar -ScriptBlock { $null }\r\nfunction Foo1 { param($Bar) }\r\n\r\n# Try the same with an [ArgumentCompleter] attribute.\r\n# Not effective. Always falls back to default completion.\r\nfunction Foo2 { param([ArgumentCompleter({ $null })] $Bar) }\r\n\r\n# With an IArgumentCompleter implementation, the logic is reversed:\r\n# Returning an *empty* [IEnumerable[CompletionResult]] suppresses the fallback.\r\n# Returning $null opts-into falling back.\r\nclass CustomCompleter : System.Management.Automation.IArgumentCompleter {\r\n  [System.Collections.Generic.IEnumerable[System.Management.Automation.CompletionResult]] CompleteArgument(\r\n        [string] $CommandName,\r\n        [string] $ParameterName,\r\n        [string] $WordToComplete,\r\n        [System.Management.Automation.Language.CommandAst] $CommandAst,\r\n        [System.Collections.IDictionary] $FakeBoundParameters\r\n  ) {\r\n    # Return empty collection to suppress fallback.\r\n    return [System.Collections.Generic.List[System.Management.Automation.CompletionResult]]::new()\r\n  }\r\n}\r\n\r\nfunction Foo3 { param([ArgumentCompleter([CustomCompleter])] $Bar) }\r\n\r\n# Perform tab-completion on all 3 functions.\r\n(TabExpansion2 'Foo1 ').CompletionMatches.Count\r\n(TabExpansion2 'Foo2 ').CompletionMatches.Count\r\n(TabExpansion2 'Foo3 ').CompletionMatches.Count\r\n```\r\n\r\n\r\n### Expected behavior\r\n\r\n```console\r\n0\r\n0\r\n0\r\n```\r\n\r\nThat is, all attempts to suppress the fallback behavior should succeed, irrespective of what completer implementation is chosen.\r\n\r\n### Actual behavior\r\n\r\n```console\r\nMethodInvocationException:\r\nLine |\r\n  39 |  …      return [System.Management.Automation.CommandCompletion]::Complet …\r\n     |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n     | Exception calling \"CompleteInput\" with \"3\" argument(s): \"Object reference not set to an instance of an object.\"\r\n0\r\n252\r\n0\r\n```\r\n\r\nThat is:\r\n\r\n* The `Register-ArgumentCompleter` script block returning `$null` causes an exception in `TabExpansion2`, but as a result effectively returns _no_ completions, i.e. suppresses fallback behavior.\r\n\r\n* By contrast, returning `$null` from the script block used with `[ArgumentCompleter()]` had _no_ effect, and fallback occurred.\r\n\r\n* The `IArgumentCompleter`-implementing instance returning an empty enumerable effectively suppressed fallback behavior.\r\n\r\n### Error details\r\n\r\n_No response_\r\n\r\n### Environment data\r\n\r\n```powershell\r\nPowerShell 7.4.0-preview.3\r\n```\r\n\r\n\r\n### Visuals\r\n\r\n_No response_","author":{"url":"https://github.com/mklement0","@type":"Person","name":"mklement0"},"datePublished":"2023-05-08T19:35:41Z","url":"https://github.com/PowerShell/PowerShell/issues/19628"}

react-profiling0
react-import-mapreact,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-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:ab5a337c-e1cf-bbff-df09-620e735deb44
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idAA92:1E6531:7524F:A6486:6AFDD6BD
html-safe-nonce869e850ea284818dc77f9fb751b5fdc7ff8d73aaa45695063beab0fcf192008c
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQTkyOjFFNjUzMTo3NTI0RjpBNjQ4Njo2QUZERDZCRCIsInZpc2l0b3JfaWQiOiIyODg2NTI5NTMwMDk1MDY0NzY1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmacdbf6668bc4e1413b99ff17ff351c4f5f1e7168419c2202fecb783c72254199bd
hovercard-subject-tagissue:1700813624
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/19628/issue_layout
twitter:imagehttps://opengraph.githubassets.com/5386f30d838a0cac0410bd4449af1b9f1714acdfdee161b5e56e4e05c04c5833/PowerShell/PowerShell/issues/19628
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/5386f30d838a0cac0410bd4449af1b9f1714acdfdee161b5e56e4e05c04c5833/PowerShell/PowerShell/issues/19628
og:image:altPrerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamemklement0
hostnamegithub.com
expected-hostnamegithub.com
None9918bd4004419458bcd838065ac2a76b76ebd11705d73909fff5ab99e996fa23
turbo-cache-controlno-preview
go-importgithub.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git
octolytics-dimension-user_id11524380
octolytics-dimension-user_loginPowerShell
octolytics-dimension-repository_id49609581
octolytics-dimension-repository_nwoPowerShell/PowerShell
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id49609581
octolytics-dimension-repository_network_root_nwoPowerShell/PowerShell
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasea231c174493a6a442c0b0544475c918b30128208
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/PowerShell/PowerShell/issues/19628#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FPowerShell%2FPowerShell%2Fissues%2F19628
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FPowerShell%2FPowerShell%2Fissues%2F19628
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=PowerShell%2FPowerShell
Reloadhttps://github.com/PowerShell/PowerShell/issues/19628
Reloadhttps://github.com/PowerShell/PowerShell/issues/19628
Reloadhttps://github.com/PowerShell/PowerShell/issues/19628
PowerShellhttps://github.com/PowerShell
PowerShellhttps://github.com/PowerShell/PowerShell
Codehttps://github.com/PowerShell/PowerShell
Issues1.3k (1.3k)https://github.com/PowerShell/PowerShell/issues
Pull requests366 (366)https://github.com/PowerShell/PowerShell/pulls
Discussionshttps://github.com/PowerShell/PowerShell/discussions
Actionshttps://github.com/PowerShell/PowerShell/actions
Projectshttps://github.com/PowerShell/PowerShell/projects
Security and quality3 (3)https://github.com/PowerShell/PowerShell/security
Insightshttps://github.com/PowerShell/PowerShell/insights
https://github.com/PowerShell/PowerShell
New issuehttps://github.com/login?return_to=https://github.com/PowerShell/PowerShell/issues/19628
New issuehttps://github.com/login?return_to=https://github.com/PowerShell/PowerShell/issues/19628
Preventing fallback to default tab-completion behavior works inconsistently between Register-ArgumentCompleter and the [ArgumentCompleter] attribute with script blockshttps://github.com/PowerShell/PowerShell/issues/19628#top
Needs-TriageThe issue is new and needs to be triaged by a work group.https://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Needs-Triage%22
Resolution-No ActivityIssue has had no activity for 6 months or morehttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Resolution-No%20Activity%22
https://github.com/mklement0
Michael Klement (mklement0)https://github.com/mklement0
on May 8, 2023https://github.com/PowerShell/PowerShell/issues/19628#issue-1700813624
latest released versionhttps://github.com/PowerShell/PowerShell/releases
FAQhttps://github.com/PowerShell/PowerShell/blob/master/docs/FAQ.md
Differences between Windows PowerShell 5.1 and PowerShellhttps://docs.microsoft.com/powershell/scripting/whats-new/differences-from-windows-powershell
Michael Klement (mklement0)https://github.com/mklement0
Needs-TriageThe issue is new and needs to be triaged by a work group.https://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Needs-Triage%22
on May 8, 2023https://github.com/PowerShell/PowerShell/issues/19628#event-9193757926
https://github.com/jhoneill
James O'Neill (jhoneill)https://github.com/jhoneill
on May 9, 2023https://github.com/PowerShell/PowerShell/issues/19628#issuecomment-1540008523
https://github.com/mklement0
Michael Klement (mklement0)https://github.com/mklement0
on May 9, 2023https://github.com/PowerShell/PowerShell/issues/19628#issuecomment-1540176644
#14147https://github.com/PowerShell/PowerShell/issues/14147
https://github.com/jhoneill
James O'Neill (jhoneill)https://github.com/jhoneill
on May 9, 2023https://github.com/PowerShell/PowerShell/issues/19628#issuecomment-1540237710
https://gist.github.com/jhoneill/f327b7913735db4ab6f1adaaa7bcf67d#file-vtformat-ps1-L29https://gist.github.com/jhoneill/f327b7913735db4ab6f1adaaa7bcf67d#file-vtformat-ps1-L29
https://camo.githubusercontent.com/cb48ae31e53fa907071be6967b913f63ddade53f7eb820351e31abe8276b4ee3/68747470733a2f2f6769746875622e6769746875626173736574732e636f6d2f696d616765732f6d6f64756c65732f67697374732f676973742d6f672d696d6167652e706e67
https://camo.githubusercontent.com/7e41d4698b37a89b2a8c06057583a5f48ce614b0fb7e2b93d27a2ec01c8f024b/68747470733a2f2f6769746875622e6769746875626173736574732e636f6d2f66617669636f6e732f66617669636f6e2e737667
VTFormat.ps1https://gist.github.com/jhoneill/f327b7913735db4ab6f1adaaa7bcf67d
https://github.com/mklement0
Michael Klement (mklement0)https://github.com/mklement0
on May 9, 2023https://github.com/PowerShell/PowerShell/issues/19628#issuecomment-1540289310
https://github.com/mklement0
Michael Klement (mklement0)https://github.com/mklement0
on May 9, 2023https://github.com/PowerShell/PowerShell/issues/19628#issuecomment-1540307525
https://github.com/apps/microsoft-github-policy-service
microsoft-github-policy-servicehttps://github.com/apps/microsoft-github-policy-service
on Nov 15, 2023https://github.com/PowerShell/PowerShell/issues/19628#issuecomment-1811615693
Microsoft GitHub Policy Servicehttps://aka.ms/1es-gitops
https://github.com/apps/microsoft-github-policy-service
microsoft-github-policy-servicehttps://github.com/apps/microsoft-github-policy-service
on Nov 15, 2023https://github.com/PowerShell/PowerShell/issues/19628#issuecomment-1811615695
Microsoft GitHub Policy Servicehttps://aka.ms/1es-gitops
microsoft-github-policy-servicehttps://github.com/apps/microsoft-github-policy-service
Resolution-No ActivityIssue has had no activity for 6 months or morehttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Resolution-No%20Activity%22
on Nov 15, 2023https://github.com/PowerShell/PowerShell/issues/19628#event-10961579832
https://github.com/apps/microsoft-github-policy-service
microsoft-github-policy-servicehttps://github.com/apps/microsoft-github-policy-service
on Nov 15, 2023https://github.com/PowerShell/PowerShell/issues/19628#issuecomment-1811654940
Microsoft GitHub Policy Servicehttps://aka.ms/1es-gitops
https://github.com/apps/microsoft-github-policy-service
microsoft-github-policy-servicehttps://github.com/apps/microsoft-github-policy-service
on Nov 22, 2023https://github.com/PowerShell/PowerShell/issues/19628#issuecomment-1822541520
Microsoft GitHub Policy Servicehttps://aka.ms/1es-gitops
microsoft-github-policy-servicehttps://github.com/apps/microsoft-github-policy-service
completedhttps://github.com/PowerShell/PowerShell/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Nov 22, 2023https://github.com/PowerShell/PowerShell/issues/19628#event-11034941140
Gilbert Sanchez (HeyItsGilbert)https://github.com/HeyItsGilbert
on Aug 11, 2026https://github.com/PowerShell/PowerShell/issues/19628#event-29259272893
fix(powershell): help text, file-prefix, native fallback, and cmd() bugshttps://github.com/HeyItsGilbert/shtab/commit/270e3799e656572c0f763c1b76b8b589afaabcdd
270e379https://github.com/HeyItsGilbert/shtab/commit/270e3799e656572c0f763c1b76b8b589afaabcdd
Casper da Costa-Luis (casperdcl)https://github.com/casperdcl
on Aug 12, 2026https://github.com/PowerShell/PowerShell/issues/19628#event-29351627794
fix help text, file-prefix, native fallback, exampleshttps://github.com/HeyItsGilbert/shtab/commit/1636aa3814af29a004729bf333cc78a93158ee33
1636aa3https://github.com/HeyItsGilbert/shtab/commit/1636aa3814af29a004729bf333cc78a93158ee33
fix help text, file-prefix, native fallback, exampleshttps://github.com/HeyItsGilbert/shtab/commit/62df24b17b04e4756505e92ef7dba3f7e1a81607
62df24bhttps://github.com/HeyItsGilbert/shtab/commit/62df24b17b04e4756505e92ef7dba3f7e1a81607
fix help text, file-prefix, native fallback, exampleshttps://github.com/HeyItsGilbert/shtab/commit/afbdcb929d63699f1ce0c09458b247f0a33cddcc
afbdcb9https://github.com/HeyItsGilbert/shtab/commit/afbdcb929d63699f1ce0c09458b247f0a33cddcc
Gilbert Sanchez (HeyItsGilbert)https://github.com/HeyItsGilbert
on Aug 20, 2026https://github.com/PowerShell/PowerShell/issues/19628#event-29714946028
fix help text, file-prefix, native fallback, exampleshttps://github.com/HeyItsGilbert/shtab/commit/9ac465340cc3f93e0aa024f161e29ab4cdaaf56a
9ac4653https://github.com/HeyItsGilbert/shtab/commit/9ac465340cc3f93e0aa024f161e29ab4cdaaf56a
Casper da Costa-Luis (casperdcl)https://github.com/casperdcl
on Aug 20, 2026https://github.com/PowerShell/PowerShell/issues/19628#event-29773325685
fix help text, file-prefix, native fallback, exampleshttps://github.com/HeyItsGilbert/shtab/commit/3213fc93b8b7471d77bffbf0a4909cb4d7dba737
3213fc9https://github.com/HeyItsGilbert/shtab/commit/3213fc93b8b7471d77bffbf0a4909cb4d7dba737
fix help text, file-prefix, native fallback, exampleshttps://github.com/HeyItsGilbert/shtab/commit/adffc9a61f868a32f4795206e1286dd9f3e95ed1
adffc9ahttps://github.com/HeyItsGilbert/shtab/commit/adffc9a61f868a32f4795206e1286dd9f3e95ed1
fix help text, file-prefix, native fallback, exampleshttps://github.com/HeyItsGilbert/shtab/commit/db07d6110562e728dd73da118d725b36e331f6f0
db07d61https://github.com/HeyItsGilbert/shtab/commit/db07d6110562e728dd73da118d725b36e331f6f0
Sign up for freehttps://github.com/signup?return_to=https://github.com/PowerShell/PowerShell/issues/19628
Sign in to commenthttps://github.com/login?return_to=https://github.com/PowerShell/PowerShell/issues/19628
Needs-TriageThe issue is new and needs to be triaged by a work group.https://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Needs-Triage%22
Resolution-No ActivityIssue has had no activity for 6 months or morehttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Resolution-No%20Activity%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.