Commit 4a961c0108720741e2683868eb10495f015ee422

Salvatore Sanfilippo 2018-07-18T18:29:05

Merge pull request #151 from hoelzro/master Set seq to empty string if color/bold not used

1
2
3
4
5
6
7
8
9
10
11
12
13
diff --git a/linenoise.c b/linenoise.c
index fce14a7..10ffd71 100644
--- a/linenoise.c
+++ b/linenoise.c
@@ -485,6 +485,8 @@ void refreshShowHints(struct abuf *ab, struct linenoiseState *l, int plen) {
             if (bold == 1 && color == -1) color = 37;
             if (color != -1 || bold != 0)
                 snprintf(seq,64,"\033[%d;%d;49m",bold,color);
+            else
+                seq[0] = '\0';
             abAppend(ab,seq,strlen(seq));
             abAppend(ab,hint,hintlen);
             if (color != -1 || bold != 0)