Implement history search --reverse (#4375)

* Implement `history search --reverse`

It should be possible to have `history search` output ordered oldest to
newest like nearly every other shell including bash, ksh, zsh, and csh.
We can't make this the default because too many people expect the
current behavior. This simply makes it possible for people to define
their own abbreviations or functions that provide behavior they are
likely used to if they are transitioning to fish from another shell.

This also fixes a bug in the `history` function with respect to how it
handles the `-n` / `--max` flag.

Fixes #4354

* Fix comment for format_history_record()
This commit is contained in:
Kurtis Rader
2017-09-14 15:44:17 -07:00
committed by Aaron Gyes
parent d0071960b8
commit ee1d310651
6 changed files with 123 additions and 56 deletions

View File

@@ -50,8 +50,8 @@ expect_prompt -re {start2\r\necho start1; builtin history; echo end1\r\nend2\r\n
# ==========
# Verify explicit searching for the first two commands in the previous tests
# returns the expected results.
send "history search echo start\r"
expect_prompt -re {\r\necho start1.*\r\necho start2} {
send "history search --reverse 'echo start'\r"
expect_prompt -re {\r\necho start1;.*\r\necho start2;} {
puts "history function explicit search succeeded"
} timeout {
puts stderr "history function explicit search failed"