From 6564257a7b55259314095afa132fb6fdbcf3e6eb Mon Sep 17 00:00:00 2001 From: Shafkath Shuhan Date: Wed, 23 Jun 2021 02:13:45 -0400 Subject: [PATCH] add missing doc --- helix-view/src/document.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs index 92778ad7c..dc0043361 100644 --- a/helix-view/src/document.rs +++ b/helix-view/src/document.rs @@ -179,6 +179,10 @@ pub fn from_reader( loop { let mut total_read = 0usize; + // An inner loop is necessary as it is possible that the input buffer + // may not be completely decoded on the first `decode_to_str()` call + // which would happen in cases where the output buffer is filled to + // capacity. loop { let (result, read, written, ..) = decoder.decode_to_str( &slice[total_read..], @@ -252,6 +256,10 @@ pub async fn to_writer<'a, W: tokio::io::AsyncWriteExt + Unpin + ?Sized>( let is_empty = chunk.is_empty(); let mut total_read = 0usize; + // An inner loop is necessary as it is possible that the input buffer + // may not be completely encoded on the first `encode_from_utf8()` call + // which would happen in cases where the output buffer is filled to + // capacity. loop { let (result, read, written, ..) = encoder.encode_from_utf8(&chunk[total_read..], &mut buf[total_written..], is_empty);