Fix inconsistencies in nodes sizes after edits

This commit is contained in:
Max Brunsfeld 2016-09-19 13:35:08 -07:00
parent ae3b912ddc
commit 3014101104
6 changed files with 70 additions and 67 deletions

View file

@ -82,7 +82,7 @@ void ts_document_edit(TSDocument *self, TSInputEdit edit) {
size_t max_bytes = ts_tree_total_bytes(self->tree);
if (edit.start_byte > max_bytes)
edit.start_byte = max_bytes;
return;
if (edit.bytes_removed > max_bytes - edit.start_byte)
edit.bytes_removed = max_bytes - edit.start_byte;