Skip to content

Commit c357357

Browse files
authored
Merge pull request #10 from shendiaomo/multiline_paste
Multiline paste
2 parents 42516e5 + 1d18ad6 commit c357357

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

prompt.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,16 @@ func (p *Prompt) readBuffer(bufCh chan []byte, stopCh chan struct{}) {
279279
return
280280
default:
281281
if b, err := p.in.Read(); err == nil && !(len(b) == 1 && b[0] == 0) {
282-
bufCh <- b
282+
start := 0
283+
for i, e := range b {
284+
switch GetKey([]byte{e}) {
285+
case Enter, ControlJ, ControlM:
286+
bufCh <- b[start:i]
287+
bufCh <- []byte{e}
288+
start = i + 1
289+
}
290+
}
291+
bufCh <- b[start:]
283292
}
284293
}
285294
time.Sleep(10 * time.Millisecond)

0 commit comments

Comments
 (0)