Pressing "up" filters history on what you've already typed
Description
I didn't have to write any code for this. It's the default behavior of JLine3, but I like it and I want to document the change so it's part of the release notes.
When hitting up arrow, if you've already typed part of a command into the prompt, the history results will be filtered to only include history items that match the partial word you've already typed. So if you type "cd" and press up arrow, you'll see only the items from history that start with "cd". If the prompt is empty, you'll get all history items like usual. The filtering is based on the first word, so even typing "cd C:/foo" and then pressing up will still filter on other "cd" commands.
Furthermore, when you press down arrow again, your original not-yet-run command is still there in the history. JLine2 used to lose your typed text when you hit up arrow.
Gliffy Diagrams
Activity
Show:
Brad Wood December 22, 2017 at 8:32 AM
A note from the author of JLine regarding getting the old behavior back if we ever want to:
By default, the command associated with the up / down keys are up-/down-line-or-search. The effect is that they use the first word of the current line when searching the history, so if you hit cd<up>, it will cycle the history, but only for entries beginning with "cd". The default can easily be reverted to using up-/down-line-or-history instead, which will perform a simple cycling in the history. Try the following:
Fixed
Pinned fields
Click on the next to a field label to start pinning.
I didn't have to write any code for this. It's the default behavior of JLine3, but I like it and I want to document the change so it's part of the release notes.
When hitting up arrow, if you've already typed part of a command into the prompt, the history results will be filtered to only include history items that match the partial word you've already typed. So if you type "cd" and press up arrow, you'll see only the items from history that start with "cd". If the prompt is empty, you'll get all history items like usual.
The filtering is based on the first word, so even typing "cd C:/foo" and then pressing up will still filter on other "cd" commands.
Furthermore, when you press down arrow again, your original not-yet-run command is still there in the history. JLine2 used to lose your typed text when you hit up arrow.