Jaykul / PowerLine

A more PowerShell prompt
MIT License
567 stars 31 forks source link

Doesn't work in Powershell Core #60

Closed LiteracyFanatic closed 3 years ago

LiteracyFanatic commented 4 years ago

I receive the following error on Arch Linux with PowerShell 7.0.0-rc.3:

WARNING: Exception in PowerLinePrompt
Cannot convert value "System.Collections.Hashtable" to type "PoshCode.Pansies.Text". Error: "Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')"
dmann18181 commented 4 years ago

I am having the same issue in macOS

rlvandaveer commented 4 years ago

I spent a little time debugging at it appears to be failing on line 115 of ./Source/Public/Get-SegmentedPath.ps1 on the cast of $buffer, an array of HashTables, to an array of PoshCode.Pansies.Text. This cast works when debugging in VSCode.

drmohundro commented 4 years ago

The error is being thrown from /Source/Public/Write-PowerlinePrompt.ps1#L203 - it looks like it is related to $Host.UI.RawUI.BackgroundColor. See https://github.com/Jaykul/PowerLine/blob/master/Source/Public/Write-PowerlinePrompt.ps1#L149 - that is where the error is getting thrown from. Note how, at https://github.com/Jaykul/PowerLine/blob/master/Source/Public/Write-PowerlinePrompt.ps1#L127, it used to use $Host.UI.RawUI.BackgroundColor but it is now $null. When I change line 149 to use $null, it seems to work for me.

I'm happy to submit a PR for this fix if I'm understanding the issue correctly.