Commit 24e401c20202939ae76914b9578fbb809ae04d67

antirez 2016-04-12T18:35:12

Use sane defaults for hints color and bold.

diff --git a/linenoise.c b/linenoise.c
index 0c1fee2..47ab864 100644
--- a/linenoise.c
+++ b/linenoise.c
@@ -475,16 +475,18 @@ static void abFree(struct abuf *ab) {
 void refreshShowHints(struct abuf *ab, struct linenoiseState *l, int plen) {
     char seq[64];
     if (hintsCallback && plen+l->len < l->cols) {
-        int color, bold;
+        int color = -1, bold = 0;
         char *hint = hintsCallback(l->buf,&color,&bold);
         if (hint) {
             int hintlen = strlen(hint);
             int hintmaxlen = l->cols-(plen+l->len);
             if (hintlen > hintmaxlen) hintlen = hintmaxlen;
-            snprintf(seq,64,"\033[%d;%d;49m",bold,color);
+            if (color != -1 || bold != 0)
+                snprintf(seq,64,"\033[%d;%d;49m",bold,color);
             abAppend(ab,seq,strlen(seq));
             abAppend(ab,hint,hintlen);
-            abAppend(ab,"\033[0m",4);
+            if (color != -1 || bold != 0)
+                abAppend(ab,"\033[0m",4);
             /* Call the function to free the hint returned. */
             if (freeHintsCallback) freeHintsCallback(hint);
         }