]> git.lizzy.rs Git - linenoise.git/commitdiff
Allow tab-completion only at the end of line
authorDennis Schridde <devurandom@gmx.net>
Fri, 2 Nov 2012 09:50:00 +0000 (10:50 +0100)
committerDennis Schridde <devurandom@gmx.net>
Fri, 2 Nov 2012 09:50:00 +0000 (10:50 +0100)
linenoise.c

index fca3849cf0b17fb1ae086e60db737096d98eb760..5e3216e4591d719df286f4ce4c886fcb17232cce 100644 (file)
@@ -955,7 +955,7 @@ static int linenoisePrompt(struct current *current) {
         /* Only autocomplete when the callback is set. It returns < 0 when
          * there was an error reading from fd. Otherwise it will return the
          * character that should be handled next. */
-        if (c == '\t' && completionCallback != NULL) {
+        if (c == '\t' && current->pos == current->chars && completionCallback != NULL) {
             c = completeLine(current);
             /* Return on errors */
             if (c < 0) return current->len;