From 131bbee1601d6b0aaa00548ce06e2226e8cc57cf Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 8 Sep 2016 17:51:34 -0700 Subject: [PATCH] Rename parse_and_diff -> parse_and_get_changed_ranges Signed-off-by: Nathan Sobo --- include/tree_sitter/runtime.h | 2 +- spec/runtime/document_spec.cc | 4 ++-- src/runtime/document.c | 7 +++++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/include/tree_sitter/runtime.h b/include/tree_sitter/runtime.h index be321720..be00a69e 100644 --- a/include/tree_sitter/runtime.h +++ b/include/tree_sitter/runtime.h @@ -103,7 +103,7 @@ void ts_document_set_logger(TSDocument *, TSLogger); void ts_document_print_debugging_graphs(TSDocument *, bool); void ts_document_edit(TSDocument *, TSInputEdit); int ts_document_parse(TSDocument *); -int ts_document_parse_and_diff(TSDocument *, TSRange **, size_t *); +int ts_document_parse_and_get_changed_ranges(TSDocument *, TSRange **, size_t *); void ts_document_invalidate(TSDocument *); TSNode ts_document_root_node(const TSDocument *); size_t ts_document_parse_count(const TSDocument *); diff --git a/spec/runtime/document_spec.cc b/spec/runtime/document_spec.cc index 9e393134..aa5ad6bb 100644 --- a/spec/runtime/document_spec.cc +++ b/spec/runtime/document_spec.cc @@ -194,7 +194,7 @@ describe("Document", [&]() { }); }); - describe("parse_and_diff()", [&]() { + describe("parse_and_get_changed_ranges()", [&]() { SpyInput *input; before_each([&]() { @@ -217,7 +217,7 @@ describe("Document", [&]() { TSRange *ranges; size_t range_count = 0; - ts_document_parse_and_diff(doc, &ranges, &range_count); + ts_document_parse_and_get_changed_ranges(doc, &ranges, &range_count); vector result; for (size_t i = 0; i < range_count; i++) diff --git a/src/runtime/document.c b/src/runtime/document.c index 22e4bb5b..3d90a482 100644 --- a/src/runtime/document.c +++ b/src/runtime/document.c @@ -165,7 +165,10 @@ static bool ts_tree_diff(TSDocument *doc, TSTree *old, TSNode *new_node, PRINT("advance before diff ('%s', %lu) -> ('%s', %lu)", NAME(new_node->data), ts_node_start_char(*new_node), NAME(next.data), ts_node_start_char(next)); + *new_node = next; + } else { + break; } } else if (new_child_start == old_child_start) { if (!ts_tree_diff(doc, old_child, new_node, depth, results, extend_last_change)) @@ -196,7 +199,7 @@ static bool ts_tree_diff(TSDocument *doc, TSTree *old, TSNode *new_node, return true; } -int ts_document_parse_and_diff(TSDocument *self, TSRange **ranges, size_t *range_count) { +int ts_document_parse_and_get_changed_ranges(TSDocument *self, TSRange **ranges, size_t *range_count) { if (ranges) *ranges = NULL; if (range_count) *range_count = 0; @@ -238,7 +241,7 @@ int ts_document_parse_and_diff(TSDocument *self, TSRange **ranges, size_t *range } int ts_document_parse(TSDocument *self) { - return ts_document_parse_and_diff(self, NULL, NULL); + return ts_document_parse_and_get_changed_ranges(self, NULL, NULL); } void ts_document_invalidate(TSDocument *self) {