Fix shell integration ps1 script for pwsh 5

Fixes #227132
pull/227134/head
Daniel Imms 2024-08-29 11:06:38 -07:00
parent 5b066ec2e3
commit 35232a70bc
No known key found for this signature in database
GPG Key ID: E5CF412B63651C69
1 changed files with 4 additions and 4 deletions

View File

@ -172,9 +172,9 @@ function Set-MappedKeyHandler {
function Get-KeywordCompletionResult(
$Keyword,
$Description = $null
$Description = $Keyword
) {
[System.Management.Automation.CompletionResult]::new($Keyword, $Keyword, [System.Management.Automation.CompletionResultType]::Keyword, $null -ne $Description ? $Description : $Keyword)
[System.Management.Automation.CompletionResult]::new($Keyword, $Keyword, [System.Management.Automation.CompletionResultType]::Keyword, $Description)
}
function Set-MappedKeyHandlers {
@ -360,7 +360,7 @@ function Send-Completions {
# completions are consistent regardless of where it was requested
elseif ($lastWord -match '[/\\]') {
$lastSlashIndex = $completionPrefix.LastIndexOfAny(@('/', '\'))
if ($lastSlashIndex -ne -1 && $lastSlashIndex -lt $cursorIndex) {
if ($lastSlashIndex -ne -1 -and $lastSlashIndex -lt $cursorIndex) {
$newCursorIndex = $lastSlashIndex + 1
$completionPrefix = $completionPrefix.Substring(0, $newCursorIndex)
$prefixCursorDelta = $cursorIndex - $newCursorIndex
@ -430,7 +430,7 @@ function Send-Completions {
# completions are consistent regardless of where it was requested
if ($completionPrefix -match '[/\\]') {
$lastSlashIndex = $completionPrefix.LastIndexOfAny(@('/', '\'))
if ($lastSlashIndex -ne -1 && $lastSlashIndex -lt $cursorIndex) {
if ($lastSlashIndex -ne -1 -and $lastSlashIndex -lt $cursorIndex) {
$newCursorIndex = $lastSlashIndex + 1
$completionPrefix = $completionPrefix.Substring(0, $newCursorIndex)
$prefixCursorDelta = $cursorIndex - $newCursorIndex