summaryrefslogtreecommitdiff
path: root/src/fe-common/core
diff options
context:
space:
mode:
authorLemonBoy <LemonBoy@users.noreply.github.com>2017-04-11 15:19:19 +0200
committerGitHub <noreply@github.com>2017-04-11 15:19:19 +0200
commitc890ecafa0ce3df1a339ae201598184ab1585d36 (patch)
tree7ae259383c1e74e1a7b63a1b434a27f9902fbb3d /src/fe-common/core
parent411ace0a15483d44b4bd0016f586108630cd5142 (diff)
parent405136440cbfd18a39e2d5aa01c812a1247c369d (diff)
downloadirssi-c890ecafa0ce3df1a339ae201598184ab1585d36.zip
Merge pull request #686 from josephbisch/remove-history-wrap
Don't allow command history to wrap around
Diffstat (limited to 'src/fe-common/core')
-rw-r--r--src/fe-common/core/command-history.c15
-rw-r--r--src/fe-common/core/command-history.h2
2 files changed, 5 insertions, 12 deletions
diff --git a/src/fe-common/core/command-history.c b/src/fe-common/core/command-history.c
index 405700e5..55474b1b 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)) {
@@ -156,7 +150,6 @@ const char *command_history_next(WINDOW_REC *window, const char *text)
void command_history_clear_pos_func(HISTORY_REC *history, gpointer user_data)
{
- history->over_counter = 0;
history->pos = NULL;
}
diff --git a/src/fe-common/core/command-history.h b/src/fe-common/core/command-history.h
index a572216b..45126092 100644
--- a/src/fe-common/core/command-history.h
+++ b/src/fe-common/core/command-history.h
@@ -7,7 +7,7 @@ typedef struct {
char *name;
GList *list, *pos;
- int lines, over_counter;
+ int lines;
int refcount;
} HISTORY_REC;