Skip to content

Commit

Permalink
Merge pull request #10 from shendiaomo/multiline_paste
Browse files Browse the repository at this point in the history
Multiline paste
  • Loading branch information
Verseth committed Jul 1, 2023
2 parents 42516e5 + 1d18ad6 commit c357357
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 @@ -279,7 +279,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 c357357

Please sign in to comment.