PoshCode / Pansies

Powershell ANSI Escape Sequences, functions for colored output, etc.
MIT License
148 stars 14 forks source link

Write-Host '&' throws exception #22

Closed powercode closed 3 years ago

powercode commented 3 years ago

Calling Write-Host '&' crashes, when the end index becomes -1.

Exception             :
    Type       : System.ArgumentOutOfRangeException
    Message    : Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'startIndex')
    ParamName  : startIndex
    TargetSite :
        Name          : IndexOf
        DeclaringType : string
        MemberType    : Method
        Module        : System.Private.CoreLib.dll
    StackTrace :
   at System.String.IndexOf(Char value, Int32 startIndex, Int32 count)
   at PoshCode.Pansies.Entities.Decode(String value) in C:\Users\Jaykul\Projects\Modules\PANSIES\Source\Assembly\Entities.cs:line 36
   at PoshCode.Pansies.Text.GetString(RgbColor foreground, RgbColor background, Object object, String separator, Boolean clear, Boolean entities, Boolean persistentColor) in C:\Users\Jaykul\Projects\Modules\PANSIES\Source\Assembly\Text.cs:line 231
   at PoshCode.Pansies.Commands.WriteHostCommand.ProcessRecord() in C:\Users\Jaykul\Projects\Modules\PANSIES\Source\Assembly\Commands\WriteHostCommand.cs:line 33
   at System.Management.Automation.CommandProcessor.ProcessRecord()
    Source     : System.Private.CoreLib
    HResult    : -2146233086
CategoryInfo          : NotSpecified: (:) [Write-Host], ArgumentOutOfRangeException
FullyQualifiedErrorId : System.ArgumentOutOfRangeException,PoshCode.Pansies.Commands.WriteHostCommand
InvocationInfo        :
    MyCommand        : Write-Host
    ScriptLineNumber : 1
    OffsetInLine     : 1
    HistoryId        : 3
    Line             : Write-Host '&'
    PositionMessage  : At line:1 char:1
                       + Write-Host '&'
                       + ~~~~~~~~~~~~~~
    InvocationName   : Write-Host
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1

Version 2.3.0

Jaykul commented 3 years ago

Should be fixed in 2.3.1