]> git.lizzy.rs Git - linenoise.git/blobdiff - linenoise.c
Show original buffer when completion is aborted
[linenoise.git] / linenoise.c
index 0ebef2e910f8772cfc9c35a7d5d858c227bccef5..b6f4d4f9bfbc2b0bcd579002d531179a1d39e6cb 100644 (file)
@@ -243,10 +243,14 @@ static int completeLine(int fd, const char *prompt, char *buf, size_t buflen, si
                     if (i == lc.len) beep();
                     break;
                 case 27: /* escape */
+                    /* Re-show original buffer */
+                    if (i < lc.len) {
+                        refreshLine(fd,prompt,buf,*len,*pos,cols);
+                    }
                     stop = 1;
                     break;
                 default:
-                    /* update buffer and return */
+                    /* Update buffer and return */
                     if (i < lc.len) {
                         nwritten = snprintf(buf,buflen,"%s",lc.cvec[i]);
                         *len = *pos = nwritten;