Commit ec5e4e8716071d021b1f68c929f3aab0ffcd16eb

lifubang 2020-03-03T08:35:19

fix masking input when there is no hintsCallback Signed-off-by: lifubang <lifubang@acmcoder.com>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
diff --git a/linenoise.c b/linenoise.c
index 6d63856..01c3b93 100644
--- a/linenoise.c
+++ b/linenoise.c
@@ -669,7 +669,8 @@ int linenoiseEditInsert(struct linenoiseState *l, char c) {
             if ((!mlmode && l->plen+l->len < l->cols && !hintsCallback)) {
                 /* Avoid a full update of the line in the
                  * trivial case. */
-                if (write(l->ofd,&c,1) == -1) return -1;
+                char d = (maskmode==1) ? '*' : c;
+                if (write(l->ofd,&d,1) == -1) return -1;
             } else {
                 refreshLine(l);
             }