console : if the suggested value is empty, do not use it but propose it as solution
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@5584 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
@@ -323,6 +323,8 @@ class console
|
|||||||
$this->debug ("Autocompletion : start='$start', end='$end'");
|
$this->debug ("Autocompletion : start='$start', end='$end'");
|
||||||
$completeArr = call_user_func ($this->completionFunction,
|
$completeArr = call_user_func ($this->completionFunction,
|
||||||
self::tokenize ($start));
|
self::tokenize ($start));
|
||||||
|
if (! is_array ($completeArr))
|
||||||
|
throw new \Exception ("Autocompletion : return is not an array");
|
||||||
$isAssoc = is_array ($completeArr) &&
|
$isAssoc = is_array ($completeArr) &&
|
||||||
array_diff_key ($completeArr, array_keys (array_keys ($completeArr)));
|
array_diff_key ($completeArr, array_keys (array_keys ($completeArr)));
|
||||||
// Remove from completeArr the proposed values which doesn't match with
|
// Remove from completeArr the proposed values which doesn't match with
|
||||||
@@ -334,10 +336,13 @@ class console
|
|||||||
if (mb_substr ($val, 0, mb_strlen ($end)) !== $end)
|
if (mb_substr ($val, 0, mb_strlen ($end)) !== $end)
|
||||||
unset ($completeArr[$key]);
|
unset ($completeArr[$key]);
|
||||||
}
|
}
|
||||||
if (count ($completeArr) === 1)
|
if (count ($completeArr) === 1 &&
|
||||||
|
($isAssoc && key ($completeArr) !== "" ||
|
||||||
|
! $isAssoc && reset ($completeArr) !== ""))
|
||||||
{
|
{
|
||||||
// One entry : add a space to put on the next
|
// One entry : add a space to put on the next
|
||||||
$this->debug ("Autocompletion : One entry : add it + ending space");
|
$this->debug ("Autocompletion : One entry not empty : ".
|
||||||
|
"add it + ending space");
|
||||||
if ($isAssoc)
|
if ($isAssoc)
|
||||||
$string = $start.key ($completeArr)." ";
|
$string = $start.key ($completeArr)." ";
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user