summaryrefslogtreecommitdiff
path: root/src/fe-common/core
diff options
context:
space:
mode:
authorJoseph Bisch <joseph.bisch@gmail.com>2017-04-06 20:27:39 -0400
committerJoseph Bisch <joseph.bisch@gmail.com>2017-04-06 20:27:39 -0400
commit7c86575b02d4f80539bcd2da3bef8195b963fa92 (patch)
treefc32f7f1673d5dd9a1c8d666ba8c6117ba9739e1 /src/fe-common/core
parent3f69e718044ac87eeb5144be6113c2be33261cd0 (diff)
downloadirssi-7c86575b02d4f80539bcd2da3bef8195b963fa92.zip
Don't allow command history to wrap around
This changes the behavior of the command history to avoid wrapping back to the bottom once the top of the history is reached.
Diffstat (limited to 'src/fe-common/core')
-rw-r--r--src/fe-common/core/command-history.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/fe-common/core/command-history.c b/src/fe-common/core/command-history.c
index 405700e5..f957d385 100644
--- a/src/fe-common/core/command-history.c
+++ b/src/fe-common/core/command-history.c
@@ -113,11 +113,9 @@ const char *command_history_prev(WINDOW_REC *window, const char *text)
pos = history->pos;
if (pos != NULL) {
- history->pos = history->pos->prev;
- if (history->pos == NULL)
- history->over_counter++;
- } else if (history->lines == 0) {
- history->over_counter++;
+ /* don't go past the first entry (no wrap around) */
+ if (history->pos->prev != NULL)
+ history->pos = history->pos->prev;
} else {
history->pos = g_list_last(history->list);
}
@@ -128,7 +126,7 @@ const char *command_history_prev(WINDOW_REC *window, const char *text)
command_history_add(history, text);
}
- return history->pos == NULL ? "" : history->pos->data;
+ return history->pos == NULL ? text : history->pos->data;
}
const char *command_history_next(WINDOW_REC *window, const char *text)
@@ -141,10 +139,6 @@ const char *command_history_next(WINDOW_REC *window, const char *text)
if (pos != NULL)
history->pos = history->pos->next;
- else if (history->over_counter > 0) {
- history->over_counter--;
- history->pos = history->list;
- }
if (*text != '\0' &&
(pos == NULL || g_strcmp0(pos->data, text) != 0)) {