Skip to content

Commit

Permalink
Fix error in handling of padding in get_changed_ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
maxbrunsfeld committed Dec 30, 2017
1 parent f3c3fd3 commit 1e04489
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/runtime/document.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ void ts_document_edit(TSDocument *self, TSInputEdit edit) {
edit.bytes_removed = max_bytes - edit.start_byte;

ts_tree_edit(self->tree, &edit);

if (self->parser.print_debugging_graphs) {
ts_tree_print_dot_graph(self->tree, self->parser.language, stderr);
}
}

void ts_document_parse(TSDocument *self) {
Expand Down
6 changes: 4 additions & 2 deletions src/runtime/get_changed_ranges.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ static void iterator_get_visible_state(const Iterator *self, Tree **tree,
uint32_t i = self->path.size - 1;

if (self->in_padding) {
while (self->path.contents[i].child_index == 0) i--;
if (i == 0) return;
i--;
}

for (; i + 1 > 0; i--) {
Expand Down Expand Up @@ -218,7 +219,8 @@ IteratorComparison iterator_compare(const Iterator *old_iter, const Iterator *ne
iterator_get_visible_state(old_iter, &old_tree, &old_alias_symbol, &old_start);
iterator_get_visible_state(new_iter, &new_tree, &new_alias_symbol, &new_start);

assert(old_tree && new_tree);
if (!old_tree && !new_tree) return IteratorMatches;
if (!old_tree || !new_tree) return IteratorDiffers;

if (old_alias_symbol == new_alias_symbol) {
if (old_start == new_start) {
Expand Down

0 comments on commit 1e04489

Please sign in to comment.