From 0c66521b231556c1d27b8d6574361003870be3de Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Thu, 22 Jun 2017 02:35:57 +0900 Subject: [PATCH] Fix handling of bracketed paste mode fzf should immediately continue consuming the buffer after discarding bracketed paste mode sequence. Close #951 --- src/tui/light.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/tui/light.go b/src/tui/light.go index e690ef9..c19c8dc 100644 --- a/src/tui/light.go +++ b/src/tui/light.go @@ -411,10 +411,12 @@ func (r *LightRenderer) escSequence(sz *int) Event { return Event{F12, 0, nil} } } - // Bracketed paste mode \e[200~ / \e[201 - if r.buffer[3] == 48 && (r.buffer[4] == 48 || r.buffer[4] == 49) && r.buffer[5] == 126 { - *sz = 6 - return Event{Invalid, 0, nil} + // Bracketed paste mode: \e[200~ ... \e[201~ + if r.buffer[3] == '0' && (r.buffer[4] == '0' || r.buffer[4] == '1') && r.buffer[5] == '~' { + // Immediately discard the sequence from the buffer and reread input + r.buffer = r.buffer[6:] + *sz = 0 + return r.GetChar() } return Event{Invalid, 0, nil} // INS case 51: