From e92db03ec83701b9932a7d8d7fe1c5c90ee5210f Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Thu, 7 Apr 2022 07:15:59 -0700 Subject: [PATCH] termwiz: add comment about bracketed paste offset --- termwiz/src/input.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/termwiz/src/input.rs b/termwiz/src/input.rs index 2fe727fa9..c4b9c8543 100644 --- a/termwiz/src/input.rs +++ b/termwiz/src/input.rs @@ -1276,7 +1276,13 @@ impl InputParser { callback(InputEvent::Paste(pasted)); self.state = InputState::Normal; } else { - self.state = InputState::Pasting(0); + // Advance our offset so that in the case where we receive a paste that + // is spread across N reads of size 8K, we don't need to search for the + // end marker in 8K, 16K, 24K etc. of text until the final buffer is received. + // Ensure that we use saturating math here for the case where the amount + // of buffered data after the begin paste is smaller than the end paste marker + // + self.state = InputState::Pasting(self.buf.len().saturating_sub(end_paste.len())); return; } }