From ecb334b6cc9b332d589034d10f848d68b5170442 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Wed, 6 Sep 2000 23:15:42 +0000 Subject: [PATCH] When pressing line down, the command line wasn't saved to history. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@653 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/fe-common/core/command-history.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/fe-common/core/command-history.c b/src/fe-common/core/command-history.c index acf7bde9..2a5e755f 100644 --- a/src/fe-common/core/command-history.c +++ b/src/fe-common/core/command-history.c @@ -32,7 +32,7 @@ static GList *cmdhist, *histpos; static int histlines; static int window_history; -void command_history_add(WINDOW_REC *window, const char *text, int prepend) +void command_history_add(WINDOW_REC *window, const char *text) { GList **pcmdhist, *link; int *phistlines; @@ -58,10 +58,7 @@ void command_history_add(WINDOW_REC *window, const char *text, int prepend) g_list_free_1(link); } - if (prepend) - *pcmdhist = g_list_prepend(*pcmdhist, g_strdup(text)); - else - *pcmdhist = g_list_append(*pcmdhist, g_strdup(text)); + *pcmdhist = g_list_append(*pcmdhist, g_strdup(text)); } const char *command_history_prev(WINDOW_REC *window, const char *text) @@ -79,7 +76,7 @@ const char *command_history_prev(WINDOW_REC *window, const char *text) if (*text != '\0' && (pos == NULL || strcmp(pos->data, text) != 0)) { /* save the old entry to history */ - command_history_add(window, text, FALSE); + command_history_add(window, text); } return *phistpos == NULL ? "" : (*phistpos)->data; @@ -92,15 +89,14 @@ const char *command_history_next(WINDOW_REC *window, const char *text) phistpos = window_history ? &window->histpos : &histpos; pos = *phistpos; - if (*phistpos == NULL) - return ""; - *phistpos = (*phistpos)->next; + if (pos != NULL) + *phistpos = (*phistpos)->next; if (*text != '\0' && (pos == NULL || strcmp(pos->data, text) != 0)) { /* save the old entry to history */ - command_history_add(window, text, TRUE); + command_history_add(window, text); } return *phistpos == NULL ? "" : (*phistpos)->data; }