1
0
mirror of https://github.com/irssi/irssi.git synced 2024-12-04 14:46:39 -05:00

Merge pull request #686 from josephbisch/remove-history-wrap

Don't allow command history to wrap around
This commit is contained in:
LemonBoy 2017-04-11 15:19:19 +02:00 committed by GitHub
commit c890ecafa0
2 changed files with 5 additions and 12 deletions

View File

@ -113,11 +113,9 @@ const char *command_history_prev(WINDOW_REC *window, const char *text)
pos = history->pos; pos = history->pos;
if (pos != NULL) { if (pos != NULL) {
history->pos = history->pos->prev; /* don't go past the first entry (no wrap around) */
if (history->pos == NULL) if (history->pos->prev != NULL)
history->over_counter++; history->pos = history->pos->prev;
} else if (history->lines == 0) {
history->over_counter++;
} else { } else {
history->pos = g_list_last(history->list); 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); 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) 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) if (pos != NULL)
history->pos = history->pos->next; history->pos = history->pos->next;
else if (history->over_counter > 0) {
history->over_counter--;
history->pos = history->list;
}
if (*text != '\0' && if (*text != '\0' &&
(pos == NULL || g_strcmp0(pos->data, 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) void command_history_clear_pos_func(HISTORY_REC *history, gpointer user_data)
{ {
history->over_counter = 0;
history->pos = NULL; history->pos = NULL;
} }

View File

@ -7,7 +7,7 @@ typedef struct {
char *name; char *name;
GList *list, *pos; GList *list, *pos;
int lines, over_counter; int lines;
int refcount; int refcount;
} HISTORY_REC; } HISTORY_REC;