Add ts_tree_edit function

This commit is contained in:
Max Brunsfeld 2015-09-15 16:00:16 -07:00
parent 296d8cc1e8
commit 0467d190fe
5 changed files with 234 additions and 42 deletions

View file

@ -8,6 +8,10 @@ static inline TSLength ts_length_add(TSLength len1, TSLength len2) {
TSLength result;
result.bytes = len1.bytes + len2.bytes;
result.chars = len1.chars + len2.chars;
if ((len1.chars > 0 && len1.bytes == 0) || (len2.chars > 0 && len2.bytes == 0))
result.bytes = 0;
return result;
}
@ -15,6 +19,10 @@ static inline TSLength ts_length_sub(TSLength len1, TSLength len2) {
TSLength result;
result.bytes = len1.bytes - len2.bytes;
result.chars = len1.chars - len2.chars;
if ((len1.chars > 0 && len1.bytes == 0) || (len2.chars > 0 && len2.bytes == 0))
result.bytes = 0;
return result;
}