Handle incomplete ESC sequence in typeahead buffer (#1350)

If an ESC char is found while processing characters,
continue to check for characters. This prevents fzf from
prematurely exiting.

Close #1349
This commit is contained in:
Michael Kelley 2018-08-07 23:43:55 -07:00 committed by Junegunn Choi
parent 1c9e7b7ea6
commit 423986996a
1 changed files with 6 additions and 1 deletions

View File

@ -297,6 +297,7 @@ func (r *LightRenderer) getBytesInternal(buffer []byte, nonblock bool) []byte {
}
buffer = append(buffer, byte(c))
pc := c
for {
c, ok = r.getch(true)
if !ok {
@ -306,9 +307,13 @@ func (r *LightRenderer) getBytesInternal(buffer []byte, nonblock bool) []byte {
continue
}
break
} else if c == ESC && pc != c {
retries = r.escDelay / escPollInterval
} else {
retries = 0
}
retries = 0
buffer = append(buffer, byte(c))
pc = c
}
return buffer