]> git.lizzy.rs Git - linenoise.git/commitdiff
Avoid ESC [ n C with n=0
authorSteve Bennett <steveb@workware.net.au>
Mon, 19 Jan 2015 05:49:49 +0000 (15:49 +1000)
committerSteve Bennett <steveb@workware.net.au>
Wed, 10 Aug 2016 00:58:59 +0000 (10:58 +1000)
Note that this can only happen if the prompt is the empty string.

linenoise.c

index fb2b6808f4c8bd275fcc94959331161d41362fe0..064fce3bf1c282b62d1306da7c0890a0ba68b8ae 100644 (file)
@@ -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);
+    }
 }
 
 /**