From 244c45e2a7cc08ca5ff04458ef0002e1ab84d2c2 Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Thu, 3 Oct 2019 18:58:40 +0000 Subject: [PATCH] console : without suggestion, $start was incorrect (missing ending space) git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@5571 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- console.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/console.php b/console.php index d94c093..fc7886e 100644 --- a/console.php +++ b/console.php @@ -297,6 +297,7 @@ class console // Manage autocompletion // {{{ { + $this->debug ("Autocompletion starting"); // Take the last part of the string without space or double quotes $pos = strrpos ($string, " "); if ($pos === false) @@ -315,9 +316,11 @@ class console { // Last char is not a space, end is the last word and start is the // begin to before last word - $start = mb_substr ($string, 0, $pos); + $start = mb_substr ($string, 0, $pos + 1); $end = mb_substr ($string, $pos + 1); + } + $this->debug ("Autocompletion : start='$start', end='$end'"); $completeArr = call_user_func ($this->completionFunction, self::tokenize ($start)); $isAssoc = is_array ($completeArr) && @@ -334,6 +337,7 @@ class console if (count ($completeArr) === 1) { // One entry : add a space to put on the next + $this->debug ("Autocompletion : One entry : add ending space"); if ($start !== "") $start .= " "; if ($isAssoc) @@ -344,6 +348,7 @@ class console elseif (count ($completeArr)) { // Multiple entries : display them to allow the user to choose + $this->debug ("Autocompletion : Multiple entries : display choices"); echo "\n"; // In associative array, the key is the possible answer to // autocompletion, and the value is the helper message @@ -382,14 +387,17 @@ class console } else { + $this->debug ("Autocompletion : Zero entry : do not change"); $string = $start.$end; } +/* if (is_array ($completeArr) && count ($completeArr)) { $cursorPos = mb_strlen ($prompt.$string) + 1; $this->rewriteLine ($prompt.$string); $this->moveCursor ($cursorPos); - } + }*/ + $this->debug ("Autocompletion : end '$prompt.$string'"); } // }}} elseif (ord ($char) === 3)