summaryrefslogtreecommitdiff
path: root/histsearch.c
diff options
context:
space:
mode:
Diffstat (limited to 'histsearch.c')
-rw-r--r--histsearch.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/histsearch.c b/histsearch.c
index d94fd6c..1cc5875 100644
--- a/histsearch.c
+++ b/histsearch.c
@@ -77,11 +77,11 @@ history_search_internal (string, direction, anchored)
if (string == 0 || *string == '\0')
return (-1);
- if (!history_length || ((i == history_length) && !reverse))
+ if (!history_length || ((i >= history_length) && !reverse))
return (-1);
- if (reverse && (i == history_length))
- i--;
+ if (reverse && (i >= history_length))
+ i = history_length - 1;
#define NEXT_LINE() do { if (reverse) i--; else i++; } while (0)