sshd/terminal: Use clearline and clearscreen codes for enterClear

Fixes emoji offset bug
This commit is contained in:
Andrey Petrov 2019-03-29 17:25:51 -04:00
parent c9b58a80fa
commit 479a391d55

View File

@ -529,11 +529,18 @@ func (t *Terminal) handleKey(key rune) (line string, ok bool) {
case keyEnter: case keyEnter:
line = string(t.line) line = string(t.line)
if t.enterClear { if t.enterClear {
// Clear line on enter instead of starting a new line. The old // Clear line on enter instead of starting a new line.
// prompt is retained. reset := []rune{
t.moveCursorToPos(0) // Clear whole line
t.clearLineToRight() keyEscape, '[', '2', 'K',
t.clearScreenBelow() // Necessary for wrapped lines // Clear screen below (for any wrapped lines)
keyEscape, '[', 'J',
}
t.queue(reset)
// We're still technically on the same line. If we don't offset the
// cursorX, then the fresh prompt could be rendered in the wrong
// position.
t.cursorX += len(reset)
} else { } else {
// Pushing the line up resets the cursor to 0,0 and we render a // Pushing the line up resets the cursor to 0,0 and we render a
// fresh prompt. // fresh prompt.