Skip to content

Commit

Permalink
Support multi-line paste
Browse files Browse the repository at this point in the history
  • Loading branch information
shendiaomo committed Oct 21, 2019
1 parent 0f95e1d commit 0d99dde
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion prompt.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,16 @@ func (p *Prompt) readBuffer(bufCh chan []byte, stopCh chan struct{}) {
return
default:
if b, err := p.in.Read(); err == nil && !(len(b) == 1 && b[0] == 0) {
bufCh <- b
start := 0
for i, e := range b {
switch GetKey([] byte{e}) {
case Enter, ControlJ, ControlM:
bufCh <- b[start:i]
bufCh <- [] byte{e}
start = i + 1
}
}
bufCh <- b[start:]
}
}
time.Sleep(10 * time.Millisecond)
Expand Down

0 comments on commit 0d99dde

Please sign in to comment.