From f76b7dd76b58dc5123fe8d229ad5b611a44f904f Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Sun, 8 Jul 2018 08:59:12 +0000 Subject: [PATCH] console : when moving to an old history, keep the position of the cursor if the user come back on the tmp stored entry git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@4273 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- console.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/console.php b/console.php index 0abffc4..cd40c01 100644 --- a/console.php +++ b/console.php @@ -491,6 +491,7 @@ class console if ($string !== "" && $historyTmp == "") { $historyTmp = $string; + $historyTmpPos = $cursorPos; } if ($historyPos > 0) { @@ -511,12 +512,14 @@ class console { $historyPos++; $string = $this->history[$historyPos]; + $cursorPos = mb_strlen ($prompt.$string) + 1; } elseif ($historyTmp !== "") { $string = $historyTmp; + $cursorPos = $historyTmpPos; + $historyTmp = ""; } - $cursorPos = mb_strlen ($prompt.$string) + 1; $this->rewriteLine ($prompt.$string); $this->moveCursor ($cursorPos); }