Skip to content

Commit 9c47b1c

Browse files
committed
Add comments explaining how we report the number of bytes written.
1 parent 481ef80 commit 9c47b1c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

crates/wasi-common/src/sandboxed_tty_writer.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,14 @@ where
113113
self.write_char('�')?;
114114

115115
if let Some(invalid_sequence_length) = error.error_len() {
116+
// An invalid sequence was encountered. Tell the application we've
117+
// written those bytes (though actually, we replaced them with U+FFFD).
116118
result += invalid_sequence_length;
119+
// Set up `input` to resume writing after the end of the sequence.
117120
input = &after_valid[invalid_sequence_length..];
118121
} else {
122+
// The end of the buffer was encountered unexpectedly. Tell the application
123+
// we've written out the remainder of the buffer.
119124
result += after_valid.len();
120125
break;
121126
}

0 commit comments

Comments
 (0)