From 423986996a2957cbd1c3975d5f7d64cffe6d946d Mon Sep 17 00:00:00 2001 From: Michael Kelley Date: Tue, 7 Aug 2018 23:43:55 -0700 Subject: [PATCH] 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 --- src/tui/light.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/tui/light.go b/src/tui/light.go index e223f4ab..1098d591 100644 --- a/src/tui/light.go +++ b/src/tui/light.go @@ -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