I'm wondering if anybody else has noticed that having the PSReadLine module installed in PowerShell seems to break the native ability it has to allow us to arrow-down through subsequent commands after using arrow-up to find and execute a previous command (Windows Command Prompt has this ability as well).
Arrow-down works fine if we just arrow-up and don't execute anything - but if we arrow-up say 3 commands and execute that, then arrow down after that does not produce commands #2 and #1 as I would expect, but rather it just acts as if we are already at the end of the history buffer. As if our "place in the history" is not saved anymore after using arrow-up to execute a previous command.
Through some testing, I've managed to track this down to PSReadLine as the culprit. When I remove this module from the session, the aforementioned functionality works fine.
This is reproduced on Windows 10 v20H2, PSv5.1 (along with many other OS versions going all the way back to Win7 SP1, and other PS versions up to/including PSv7.1). The issue definitely seems to be with the module.
From searching, I've only found one other thread that mentions this:
...but no resolution. I'm a bit surprised there isn't more out there on this.
Does anyone have any idea what is causing this? Is there some configuration I can change in PSReadLine to get the old behavior back?
Any help is much appreciated!
The easiest workaround is to temporarily disable PSReadLine with
Remove-Module PSReadLine
. You can then re-enable it withInstall-Module PSReadLine
.This feels like an intentional design choice to me, but you should consider reporting it as an issue on PSReadLine's GitHub: https://github.com/PowerShell/PSReadLine. Provide an explicit step-by-step reproducible sequence of the behavior you see and the behavior you're expecting. My guess is that they've chosen to model PSReadLine after other shells' behavior, so I wouldn't expect to get a lot of traction. Either way, you will probably get an explanation.