-
Notifications
You must be signed in to change notification settings - Fork 290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[scripts/posh-vcpkg] Change TabExpansion to Register-ArgumentCompleter #1512
Conversation
Waiting Test
|
5ff6ef7
to
dced1f3
Compare
44690ed
to
1f43818
Compare
e14a7c2
to
fb13f71
Compare
fb13f71
to
a3a8d1f
Compare
686cb63
to
c56f17d
Compare
3eb6c32
to
4140534
Compare
4140534
to
a3e37b5
Compare
a3e37b5
to
7b9ddf1
Compare
@@ -101,9 +103,10 @@ try { | |||
Set-Content -Path "out/scripts/buildsystems/msbuild/vcpkg.props" -Value $propsContent -NoNewline -Encoding Ascii | |||
|
|||
Copy-Item -Path "$PSScriptRoot/vcpkg.targets" -Destination 'out/scripts/buildsystems/msbuild/vcpkg.targets' | |||
New-Item -Path 'out/scripts/posh-vcpkg/0.0.1' -ItemType 'Directory' -Force |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No comments fund about the version-directory.
If the original intention is to load the latest version:
- For users, the higher version overwrites the lower version
- For developers, the command
Get-Module -ListAvailable -Refresh
is required when refreshing the module cache.
So, removing it to avoid changing this script again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Requires test for Azure pipeline of vcpkg.
& $matches['vcpkgexe'] autocomplete $matches['remaining'] | ||
return | ||
} | ||
[PowerShell]$cmd = [PowerShell]::Create().AddScript{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prevent vcpkg errors passing to user shell
vcpkg autocomplete install --triplet
error: the option 'triplet' requires a value
if ($cursorPosition -lt $commandAst.CommandElements[0].Extent.EndOffset) { | ||
return | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
e.g. & ^ vcpkg ver
Return no output to fall back to default file name completion.
'TabExpansion' | ||
) | ||
if ($cmd.HadErrors -or $completions.Count -eq 0) { | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
e.g. vcpkg install versions^
(No port named versions
but directory .\versions\
)
Unable to prevent fallback to default completion.
(Unless get an error, like return empty string.)
It will fallback default with:
return
return $null
return @()
return [System.Collections.Generic.List[System.Management.Automation.CompletionResult]]::new()
Thanks for the improvement! |
Fixes for microsoft/vcpkg#38184
The function
TabExpansion
is not supported by PowerShell 7.4.0, which breaks theposh-vcpkg.psm1
forvcpkg integrate powershell
.Use
Register-ArgumentCompleter
instead ofTabExpansion
to fix it.Change
posh-vcpkg
module to non-version directoryposh-vcpkg.psd1
minimum version from 5.0 to 5.1TabExpansion
withRegister-ArgumentCompleter
Pester
for e2e testsend-to-end-tests-dir/autocomplete-posh-vcpkg.ps1
e2e-specs/autocomplete-posh-vcpkg.Tests.ps1
Test
Test passes locally on
7.4.2
with Pester5.6.1
on Linux7.4.3
with Pester5.6.1
on macOS7.4.6
with Pester5.6.1
on Windows5.1
with Pester5.6.1
on WindowsCore
PowerShell/issues/2912