sshd/terminal: Fix mid-line enter and reflow bugs

This commit is contained in:
Andrey Petrov 2019-03-19 12:09:54 -04:00
parent 4240130978
commit 8b710da728

View File

@ -511,22 +511,23 @@ func (t *Terminal) handleKey(key rune) (line string, ok bool) {
} }
} }
case keyEnter: case keyEnter:
t.moveCursorToPos(len(t.line))
line = string(t.line) line = string(t.line)
if t.ClearLine { if t.ClearLine {
// Clear line on enter instead of starting a new line // Clear line on enter instead of starting a new line. The old
t.eraseNPreviousChars(t.pos) // prompt is retained.
ok = true t.moveCursorToPos(0)
return t.clearLineToRight()
} else {
// Pushing the line up resets the cursor to 0,0 and we render a
// fresh prompt.
t.moveCursorToPos(len(t.line))
t.queue([]rune("\r\n"))
t.cursorX = 0
t.cursorY = 0
} }
t.queue([]rune("\r\n"))
ok = true ok = true
t.line = t.line[:0] t.line = t.line[:0]
t.pos = 0 t.pos = 0
t.cursorX = 0
t.cursorY = 0
t.maxLine = 0 t.maxLine = 0
case keyDeleteWord: case keyDeleteWord:
// Delete zero or more spaces and then one or more characters. // Delete zero or more spaces and then one or more characters.