Skip to content

Commit 0a29e44

Browse files
authored
Use latest PSReadLine (#745)
* Use PSRL release and filter out previous betas * Use fully qualified type name for broad PowerShell support * Fix CI module installation
1 parent b639a13 commit 0a29e44

File tree

5 files changed

+26
-23
lines changed

5 files changed

+26
-23
lines changed

PowerShellEditorServices.build.ps1

-18
Original file line numberDiff line numberDiff line change
@@ -310,24 +310,6 @@ task RestorePsesModules -After Build {
310310
Save-Module @splatParameters
311311
}
312312

313-
# TODO: Replace this with adding a new module to Save when a new PSReadLine release comes out to the Gallery
314-
if (-not (Test-Path $PSScriptRoot/module/PSReadLine))
315-
{
316-
Write-Host "`tInstalling module: PSReadLine"
317-
318-
# Download AppVeyor zip
319-
$jobId = (Invoke-RestMethod https://ci.appveyor.com/api/projects/lzybkr/PSReadLine).build.jobs[0].jobId
320-
Invoke-RestMethod https://ci.appveyor.com/api/buildjobs/$jobId/artifacts/bin%2FRelease%2FPSReadLine.zip -OutFile $PSScriptRoot/module/PSRL.zip
321-
322-
# Position PSReadLine
323-
Expand-Archive $PSScriptRoot/module/PSRL.zip $PSScriptRoot/module/PSRL
324-
Move-Item $PSScriptRoot/module/PSRL/PSReadLine $PSScriptRoot/module
325-
326-
# Clean up
327-
Remove-Item -Force -Recurse $PSScriptRoot/module/PSRL.zip
328-
Remove-Item -Force -Recurse $PSScriptRoot/module/PSRL
329-
}
330-
331313
Write-Host "`n"
332314
}
333315

appveyor.yml

+6-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@ environment:
1414

1515
install:
1616
- ps: |
17-
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force | Out-Null
17+
Get-Module PowerShellGet,PackageManagement | Remove-Module -Force -Verbose
18+
powershell -Command { Install-Module -Name PowershellGet -MinimumVersion 1.6 -force -confirm:$false -verbose }
19+
powershell -Command { Install-Module -Name PackageManagement -MinimumVersion 1.1.7.0 -Force -Confirm:$false -Verbose }
20+
Import-Module -Name PowerShellGet -MinimumVersion 1.6 -Force
21+
Import-Module -Name PackageManagement -MinimumVersion 1.1.7.0 -Force
22+
Install-PackageProvider -Name NuGet -Force | Out-Null
1823
Import-PackageProvider NuGet -Force | Out-Null
1924
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted | Out-Null
2025
Install-Module InvokeBuild -MaximumVersion 5.1.0 -Scope CurrentUser -Force | Out-Null

modules.json

+5
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,10 @@
88
"MinimumVersion":"1.0",
99
"MaximumVersion":"1.99",
1010
"AllowPrerelease":false
11+
},
12+
"PSReadLine":{
13+
"MinimumVersion":"2.0.0-beta3",
14+
"MaximumVersion":"2.1",
15+
"AllowPrerelease":true
1116
}
1217
}

scripts/travis.ps1

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
1+
Get-Module PowerShellGet,PackageManagement | Remove-Module -Force -Verbose
2+
powershell -Command { Install-Module -Name PowershellGet -MinimumVersion 1.6 -Scope CurrentUser -force -confirm:$false -verbose }
3+
powershell -Command { Install-Module -Name PackageManagement -MinimumVersion 1.1.7.0 -Scope CurrentUser -Force -Confirm:$false -Verbose }
4+
Import-Module -Name PowerShellGet -MinimumVersion 1.6 -Force
5+
Import-Module -Name PackageManagement -MinimumVersion 1.1.7.0 -Force
6+
Install-PackageProvider -Name NuGet -Force | Out-Null
7+
Import-PackageProvider NuGet -Force | Out-Null
8+
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted | Out-Null
29

310
# Install InvokeBuild
411
Install-Module InvokeBuild -MaximumVersion 5.1.0 -Scope CurrentUser -Force

src/PowerShellEditorServices/Session/PSReadLinePromptContext.cs

+7-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ internal class PSReadLinePromptContext : IPromptContext {
2020
[System.Diagnostics.DebuggerHidden()]
2121
[System.Diagnostics.DebuggerStepThrough()]
2222
param()
23-
return [Microsoft.PowerShell.PSConsoleReadLine]::ReadLine(
23+
return [Microsoft.PowerShell.PSConsoleReadLine, Microsoft.PowerShell.PSReadLine2, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null]::ReadLine(
2424
$Host.Runspace,
2525
$ExecutionContext,
2626
$args[0])";
@@ -30,13 +30,17 @@ internal class PSReadLinePromptContext : IPromptContext {
3030
[System.Diagnostics.DebuggerStepThrough()]
3131
param()
3232
end {
33-
$module = Get-Module -ListAvailable PSReadLine | Where-Object Version -ge '2.0.0' | Sort-Object -Descending Version | Select-Object -First 1
33+
$module = Get-Module -ListAvailable PSReadLine |
34+
Where-Object Version -eq '2.0.0' |
35+
Where-Object { $_.PrivateData.PSData.Prerelease -notin 'beta1','beta2' } |
36+
Sort-Object -Descending Version |
37+
Select-Object -First 1
3438
if (-not $module) {
3539
return
3640
}
3741
3842
Import-Module -ModuleInfo $module
39-
return 'Microsoft.PowerShell.PSConsoleReadLine' -as [type]
43+
return [Microsoft.PowerShell.PSConsoleReadLine, Microsoft.PowerShell.PSReadLine2, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null]
4044
}";
4145

4246
private readonly PowerShellContext _powerShellContext;

0 commit comments

Comments
 (0)