Fix error in changed ranges calculation

There was an error in the way that we calculate the reference
scope sequences that are used as the basis for assertions about
changed ranges in randomized tests. The error caused some
characters' scopes to not be checked. This corrects the reference
implementation and fixes a previously uncaught bug in the
implementation of `tree_path_get_changed_ranges`.

Previously, when iterating over the old and new trees, we would
only perform comparisons of visible nodes. This resulted in a failure
to do any comparison for portions of the text in which there were
trailing invisible child nodes (e.g. trailing `_line_break` nodes
inside `statement` nodes in the JavaScript grammar).

Now, we additionally perform comparisons at invisible leaf nodes,
based on their lowest visible ancestor.
This commit is contained in:
Max Brunsfeld 2017-01-24 12:48:47 -08:00
parent 0a286d41f3
commit 896254eea5
4 changed files with 86 additions and 74 deletions

View file

@ -21,12 +21,11 @@ static inline void length_set_unknown_chars(Length *self) {
}
static inline Length length_min(Length len1, Length len2) {
return (len1.chars < len2.chars) ? len1 : len2;
return (len1.bytes < len2.bytes) ? len1 : len2;
}
static inline Length length_add(Length len1, Length len2) {
Length result;
result.chars = len1.chars + len2.chars;
result.bytes = len1.bytes + len2.bytes;
result.extent = point_add(len1.extent, len2.extent);
@ -57,10 +56,4 @@ static inline Length length_zero() {
return (Length){ 0, 0, {0, 0} };
}
static inline bool length_eq(Length self, Length other) {
return self.bytes == other.bytes && self.chars == other.chars &&
self.extent.row == other.extent.row &&
self.extent.column == other.extent.column;
}
#endif