diff --git a/sshd/terminal/terminal.go b/sshd/terminal/terminal.go index ec04e8f..998c79d 100644 --- a/sshd/terminal/terminal.go +++ b/sshd/terminal/terminal.go @@ -264,6 +264,10 @@ func (t *Terminal) moveCursorToPos(pos int) { return } + if pos > len(t.line) { + pos = len(t.line) + } + x := visualLength(t.prompt) + visualLength(t.line[:pos]) y := x / t.termWidth x = x % t.termWidth