From 9359257cac6750e875ba95d726543c98708fba14 Mon Sep 17 00:00:00 2001 From: abitmore Date: Sat, 4 May 2019 19:52:36 -0400 Subject: [PATCH] Avoid re-position in do_insert_hist --- src/editline.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/editline.c b/src/editline.c index 7c09e51..7bc5ef7 100644 --- a/src/editline.c +++ b/src/editline.c @@ -580,14 +580,27 @@ const char *el_prev_hist(void) static el_status_t do_insert_hist(const char *p) { + const char *pc; + if (p == NULL) return el_ring_bell(); - clear_line(); + while (rl_point > 0) + { + --rl_point; + pc = &rl_line_buffer[rl_point]; + tty_back(); + if (ISCTL(*pc)) { + tty_back(); + } else if (rl_meta_chars && ISMETA(*pc)) { + tty_back(); + tty_back(); + } + } - rl_point = 0; - reposition(); + ceol(); rl_end = 0; + rl_line_buffer[0] = '\0'; return insert_string(p); }