PSReadLine icon indicating copy to clipboard operation
PSReadLine copied to clipboard

Set-PSReadlineOption -MaximumHistoryCount in PowerShell profile does not set correctly

Open DoCode opened this issue 5 years ago • 3 comments

Environment

PS version: 7.0.0-rc.2
PSReadline version: 2.0.0-rc2'; ProjectUri = 'https://github.com/PowerShell/PSReadLine
os: 10.0.18362.1 (WinBuild.160101.0800)
PS file version: 7.0.0.0
HostName: ConsoleHost
BufferWidth: 136
BufferHeight: 9000

Steps to reproduce

Set the MaximumHistoryCount in the PowerShell profile:

Import-Module PSReadLine
Set-PSReadlineOption -MaximumHistoryCount 100

Expected behavior

Get the MaximumHistoryCount in a started session:

Get-PSReadLineOption | select MaximumHistoryCount

MaximumHistoryCount
-------------------
                100

Actual behavior

Get the MaximumHistoryCount in a started session:

Get-PSReadLineOption | select MaximumHistoryCount

MaximumHistoryCount
-------------------
               4096

DoCode avatar Jan 22 '20 21:01 DoCode

Updated the repro step to use 100 instead of [int]::MaxValue, as the latter will result in a out-of-memory exception if it works as expected, by trying to create an array of the size [int]::MaxValue.

This happens because DelayedOneTimeInitialize always set the MaximumHistoryCount to the value of $MaximumHistoryCount, even if the value has been set through Set-PSReadLineOption beforehand.

daxian-dbw avatar Jan 23 '20 19:01 daxian-dbw

Reproduced in 2.3.4 and 7.3.8.

StevenBucher98 avatar Oct 30 '23 17:10 StevenBucher98

This is still an issue in 7.4.0. 3 years, so why hasn't this been fixed already?

# Set-Variable -Name MaximumHistoryCount -Value 8192
# (Get-PSReadLineOption).MaximumHistoryCount
4096

Is there a work around?

eabase avatar Dec 08 '23 15:12 eabase