From 5187861b699c1f1b86af01d96516ab30458c9d26 Mon Sep 17 00:00:00 2001 From: kl4ng Date: Sun, 23 Feb 2014 14:22:45 -0500 Subject: [PATCH] down arrow returns empty string if at end of history --- src/toxic_strings.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/toxic_strings.c b/src/toxic_strings.c index 15cff71..11d6ad0 100644 --- a/src/toxic_strings.c +++ b/src/toxic_strings.c @@ -120,19 +120,21 @@ void add_line_to_hist(const wchar_t *buf, size_t len, wchar_t (*hst)[MAX_STR_SIZ } /* copies history item at hst_pos to buf. Sets pos and len to the len of the history item. - hst_pos is decremented or incremented depending on key_dir. */ + hst_pos is decremented or incremented depending on key_dir. + + resets buffer if at end of history */ void fetch_hist_item(wchar_t *buf, size_t *pos, size_t *len, wchar_t (*hst)[MAX_STR_SIZE], int hst_tot, int *hst_pos, int key_dir) { if (key_dir == LN_HIST_MV_UP) { if (--(*hst_pos) < 0) { - ++(*hst_pos); + (*hst_pos) = 0; beep(); } } else { if (++(*hst_pos) >= hst_tot) { - --(*hst_pos); - beep(); + (*hst_pos) = hst_tot; + reset_buf(buf, pos, len); return; } }