Commit fc9667a81d43911a6690fb1e68c16e6e3bb8df05

Salvatore Sanfilippo 2020-03-05T10:44:35

Merge pull request #183 from lifubang/fixmasking fix masking input when there is no hintsCallback

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);
             }