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
This commit is contained in:
2019-10-03 18:58:40 +00:00
parent 09c1a31d24
commit 244c45e2a7

View File

@@ -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)