Commit 2eb4956846c64f162f83a99c1ab7cc87708d7cf0

antirez 2016-04-13T12:19:04

Clear hints after newline.

diff --git a/linenoise.c b/linenoise.c
index 368cd05..a807d9b 100644
--- a/linenoise.c
+++ b/linenoise.c
@@ -815,6 +815,14 @@ static int linenoiseEdit(int stdin_fd, int stdout_fd, char *buf, size_t buflen, 
             history_len--;
             free(history[history_len]);
             if (mlmode) linenoiseEditMoveEnd(&l);
+            if (hintsCallback) {
+                /* Force a refresh without hints to leave the previous
+                 * line as the user typed it after a newline. */
+                linenoiseHintsCallback *hc = hintsCallback;
+                hintsCallback = NULL;
+                refreshLine(&l);
+                hintsCallback = hc;
+            }
             return (int)l.len;
         case CTRL_C:     /* ctrl-c */
             errno = EAGAIN;
diff --git a/linenoise.h b/linenoise.h
index 3138c1f..ed20232 100644
--- a/linenoise.h
+++ b/linenoise.h
@@ -50,7 +50,7 @@ typedef struct linenoiseCompletions {
 
 typedef void(linenoiseCompletionCallback)(const char *, linenoiseCompletions *);
 typedef char*(linenoiseHintsCallback)(const char *, int *color, int *bold);
-typedef char*(linenoiseFreeHintsCallback)(char *);
+typedef void(linenoiseFreeHintsCallback)(void *);
 void linenoiseSetCompletionCallback(linenoiseCompletionCallback *);
 void linenoiseSetHintsCallback(linenoiseHintsCallback *);
 void linenoiseSetFreeHintsCallback(linenoiseFreeHintsCallback *);