You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I set a hotkey for AcceptAndGetNext I expect to be able to replay a few commands from history in order, by just pressing it repeatedly, but it keeps skipping commands.
Quick guess ... AcceptLineImpl() is saving this new line in to the history, or changing up the history indexing, causing the next command to bump up one ?? Maybe a history item at the end is being bumped off? So until your history fills up, its not a problem, and the testing works as expected because its always starting with an empty history.
Not quite what I guessed, but I was close. Once the _history<HistoryQueue> fills, the _head moves, changing the index of every _history item. Every command is moved or copied to the _tail of the queue upon being accepted (but not in AcceptLineImpl(), instead its after returning to InputLoop() from ProcessOneKey()).
In this case, it is useless to save index's to <HistoryQueue>, because they will change once the queue is fully populated.
The problem here is probably that the index value for <HistoryQueue> is absolute, instead of relative. Currently, _history.Count represents the present, and values less than that represent fixed points in the past, but they are only fixed points until the entire history rotates in place when the queue fills.
Bash readline seems to have the same problem? I just tested in git bash 5.2.37(1)-release.
EDIT: bash readline has same problem when HISCONTROL contains earsedups, so I guess PSReadline might have similar source of problem.
EDIT: effectively they are similar problems, bash readline erases entries in middle, PSReadline dequeues entries.
Activity
lzybkr commentedon Oct 19, 2019
Weird, I know this used to work and there are even unit tests for this binding that in theory are passing.
msftrncs commentedon Dec 17, 2019
Adding some detail:
UpArrow 5 times. Then CTRL+k 5 times, the results are ...
At this point there are no more commands left, so the prompt has no further command.
So it seems as though it must be running through the right commands by some index, but then places the wrong command in the buffer...
msftrncs commentedon Dec 17, 2019
Quick guess ... AcceptLineImpl() is saving this new line in to the history, or changing up the history indexing, causing the next command to bump up one ?? Maybe a history item at the end is being bumped off? So until your history fills up, its not a problem, and the testing works as expected because its always starting with an empty history.
msftrncs commentedon Dec 18, 2019
Not quite what I guessed, but I was close. Once the
_history<HistoryQueue>fills, the_headmoves, changing the index of every_historyitem. Every command is moved or copied to the_tailof the queue upon being accepted (but not inAcceptLineImpl(), instead its after returning toInputLoop()fromProcessOneKey()).In this case, it is useless to save index's to
<HistoryQueue>, because they will change once the queue is fully populated.The problem here is probably that the index value for
<HistoryQueue>is absolute, instead of relative. Currently,_history.Countrepresents the present, and values less than that represent fixed points in the past, but they are only fixed points until the entire history rotates in place when the queue fills.Jaykul commentedon Jan 12, 2021
For what it's worth, this only happens when the history buffer is full.
StevenBucher98 commentedon Oct 30, 2023
Still reproduces in PS 7.3.8 and PSReadLine 2.3.4
sharpchen commentedon Sep 5, 2026
Bash readline seems to have the same problem? I just tested in git bash 5.2.37(1)-release.
EDIT: bash readline has same problem when
HISCONTROLcontainsearsedups, so I guess PSReadline might have similar source of problem.EDIT: effectively they are similar problems, bash readline erases entries in middle, PSReadline dequeues entries.