mirror of
https://github.com/golang/term.git
synced 2026-02-09 04:06:04 +03:00
Handle CR+LF: consume LF after CR, to avoid empty extra lines in dos new line content
This commit is contained in:
@@ -813,6 +813,10 @@ func (t *Terminal) readLine() (line string, err error) {
|
||||
if !t.pasteActive {
|
||||
lineIsPasted = false
|
||||
}
|
||||
// If we have CR, consume LF if present (CRLF sequence) to avoid returning an extra empty line.
|
||||
if key == keyEnter && len(rest) > 0 && rest[0] == keyLF {
|
||||
rest = rest[1:]
|
||||
}
|
||||
line, lineOk = t.handleKey(key)
|
||||
}
|
||||
if len(rest) > 0 {
|
||||
|
||||
Reference in New Issue
Block a user