From 7548e196113f5e4663e0fff955c5dbfdc0ae6357 Mon Sep 17 00:00:00 2001 From: Steve Bennett Date: Mon, 19 Jan 2015 15:49:49 +1000 Subject: [PATCH] Avoid ESC [ n C with n=0 Note that this can only happen if the prompt is the empty string. --- linenoise.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/linenoise.c b/linenoise.c index fb2b680..064fce3 100644 --- a/linenoise.c +++ b/linenoise.c @@ -320,7 +320,12 @@ static void eraseEol(struct current *current) static void setCursorPos(struct current *current, int x) { - fd_printf(current->fd, "\r\x1b[%dC", x); + if (x == 0) { + cursorToLeft(current); + } + else { + fd_printf(current->fd, "\r\x1b[%dC", x); + } } /** -- 2.44.0