Bugfix history cursor position

* Added check to make sure that the cursor does not remain past
  the end of the line when scrolling to a shorter entry.
This commit is contained in:
Chris 2024-02-28 12:38:39 +01:00
parent 6eddf0e847
commit 14f1d7f0cf

View File

@ -118,6 +118,7 @@ class Shell implements WritableStreamInterface, EventEmitterInterface
$this->historyIndex++;
$this->buffer = $this->history[$this->historyIndex];
}
$this->cursorPos = min(strlen($this->buffer), $this->cursorPos) - $this->scrollOffset;
break;
case "\e[B": // down
if ($this->historyIndex === null) {
@ -130,6 +131,7 @@ class Shell implements WritableStreamInterface, EventEmitterInterface
$this->historyIndex--;
$this->buffer = $this->history[$this->historyIndex];
}
$this->cursorPos = min(strlen($this->buffer), $this->cursorPos) - $this->scrollOffset;
break;
case "\e[H": // home