-
Notifications
You must be signed in to change notification settings - Fork 335
[scripts/posh-vcpkg] Change TabExpansion to Register-ArgumentCompleter #1512
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
Conversation
Waiting Test
|
| 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 -Refreshis 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 --tripleterror: 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:
returnreturn $nullreturn @()return [System.Collections.Generic.List[System.Management.Automation.CompletionResult]]::new()
|
Thanks for the improvement! |
Fixes for microsoft/vcpkg#38184
The function
TabExpansionis not supported by PowerShell 7.4.0, which breaks theposh-vcpkg.psm1forvcpkg integrate powershell.Use
Register-ArgumentCompleterinstead ofTabExpansionto fix it.Change
posh-vcpkgmodule to non-version directoryposh-vcpkg.psd1minimum version from 5.0 to 5.1TabExpansionwithRegister-ArgumentCompleterPesterfor e2e testsend-to-end-tests-dir/autocomplete-posh-vcpkg.ps1e2e-specs/autocomplete-posh-vcpkg.Tests.ps1Test
Test passes locally on
7.4.2with Pester5.6.1on Linux7.4.3with Pester5.6.1on macOS7.4.6with Pester5.6.1on Windows5.1with Pester5.6.1on WindowsCorePowerShell/issues/2912