From ddeca171a05393f84bc2e1b0d3ad692a5e8feb0c Mon Sep 17 00:00:00 2001 From: Rodrigo Martins Date: Sat, 7 Dec 2019 18:29:33 -0300 Subject: [PATCH] Add input line text to history on UP and DOWN --- src/toxic_strings.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/toxic_strings.c b/src/toxic_strings.c index 45f607e..2cc6feb 100644 --- a/src/toxic_strings.c +++ b/src/toxic_strings.c @@ -236,6 +236,13 @@ void add_line_to_hist(ChatContext *ctx) resets line if at end of history */ void fetch_hist_item(ChatContext *ctx, int key_dir) { + if(wcscmp(ctx->line, L"\0") != 0 + && ctx->hst_pos == ctx->hst_tot) + { + add_line_to_hist(ctx); + ctx->hst_pos--; + } + if (key_dir == KEY_UP) { if (--ctx->hst_pos < 0) { ctx->hst_pos = 0;