From b97ad8e5b58061920f48d32f0343f66d5896a934 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Riel=C3=A4nder?= Date: Sat, 20 Mar 2021 12:16:14 +0100 Subject: [PATCH] Fix history cycling Previously, the displayed command didn't change when switching cycling direction. This resolves the issue. --- src/history.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/history.c b/src/history.c index cf7f966..16c024e 100644 --- a/src/history.c +++ b/src/history.c @@ -151,6 +151,7 @@ const char *imrsh_history_prev(const struct imrsh_history *history, { if (cursor->prev == NULL) { cursor->prev = history->tail; + return cursor->prev->cmd; } if (cursor->prev == history->entries) { return cursor->prev->cmd; @@ -158,7 +159,7 @@ const char *imrsh_history_prev(const struct imrsh_history *history, struct imrsh_history_entry *prev = cursor->prev; cursor->next = prev; cursor->prev = prev->prev; - return prev->cmd; + return cursor->prev->cmd; } const char *imrsh_history_next(const struct imrsh_history *history, @@ -171,5 +172,5 @@ const char *imrsh_history_next(const struct imrsh_history *history, struct imrsh_history_entry *next = cursor->next; cursor->prev = next; cursor->next = next->next; - return next->cmd; + return cursor->prev->cmd; } -- 2.45.2