scribe icon indicating copy to clipboard operation
scribe copied to clipboard

Fix a bug in the read function

Open fivemoreminix opened this issue 4 years ago • 0 comments

In line 124 of gap_buffer.rs, we find:

String::from_utf8_lossy(&self.data[start_offset..end_offset]).into_owned()

The end_offset is actually an index of a character at the end of the range. This character index should be included in the slice. The same applies to one earlier line: line 113.

This proposal modifies the two broken lines of code to use ..=end_offset instead. Another solution would be ..end_offset+1.

This proposal might change some behavior in code that relied upon the faulty read function. My contribution is licensed MIT.

Thanks!

fivemoreminix avatar Jun 11 '20 22:06 fivemoreminix