Skip to content

Update tab completions for compatibility with PowerShell 7.4+ #3364

@yan12125

Description

@yan12125

Checklist

  • I have verified this is the correct repository for opening this issue.
  • I have verified no other issues exist related to my problem.
  • I have verified this is not an issue for a specific package.
  • I have verified this issue is not security related.
  • I confirm I am using official, and not unofficial, or modified, Chocolatey products.

What You Are Seeing?

Hitting tab after typing choco only shows filenames

What is Expected?

Choco commands like install, upgrade, etc. should be shown

How Did You Get This To Happen?

  1. Make sure PowerShell profile contains the following snippet
$ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
if (Test-Path($ChocolateyProfile)) {
  Import-Module "$ChocolateyProfile"
}
  1. Upgrade PowerShell to 7.4.0
  2. Type choco and hit tab

System Details

  • Operating System: 10.0.19045.0
  • Windows PowerShell version:
Name                           Value
----                           -----
PSVersion                      7.4.0
PSEdition                      Core
GitCommitId                    7.4.0
OS                             Microsoft Windows 10.0.19045
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
  • Chocolatey CLI Version: 2.2.2
  • Chocolatey Licensed Extension version: N/A - 0 packages installed.
  • Chocolatey License type: Open Source
  • Terminal/Emulator: PowerShell Core 7.4.0 on Microsoft Terminal 1.18.3181.0

Installed Packages

au 2022.10.24
chocolatey 2.2.2
chocolatey-compatibility.extension 1.0.0
chocolatey-core.extension 1.4.0
chocolatey-windowsupdate.extension 1.0.5
dellcommandupdate 5.1.0
delta 0.16.5
DotNet4.6.1 4.6.1055.20170308
Firefox 120.0.0
git.install 2.43.0
gnupg 2.4.3
KB2919355 1.0.20160915
KB2919442 1.0.20160915
KB2999226 1.0.20181019
KB3033929 1.0.5
KB3035131 1.0.3
KB3118401 1.0.5
kdeconnect-kde 23.4.0
keepassxc 2.7.6
libreoffice-still 7.5.8
microsoft-windows-terminal 1.18.3181
miktex.install 23.10.12
neovim 0.9.4
nodejs-lts 20.10.0
notepadplusplus.install 8.6.0
PIME 1.3.0
powershell-core 7.4.0
python39 3.9.13.20230703
ripgrep 13.0.0.20220913
syncthingtray 1.4.9
synergy 1.14.6.19
texstudio.install 4.6.3
vcredist140 14.38.33130
vcredist2015 14.0.24215.20170201

Output Log

(N/A - not sure how to get logs for tab completion)

Additional Context

The cause is that Chocolatey only defines TabExpansion function to enable completions, while that function is no longer used by PowerShell 7.4 [1]. A solution might be adding TabExpansion2 function (supported since PowerShell 3) besides the existing TabExpansion function, so that all users with PowerShell 2 ~ 7.4 can have Chocolatey tab completions.

As a side note, if TabExpansion2 is added, #2255 will likely be solved as well.

[1] PowerShell/PowerShell#18337

Metadata

Metadata

Assignees

Labels

5 - ReleasedThe issue has been resolved, and released to the public for consumption.BugIssues where something has happened which was not expected or intended.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions