Add ts_tree_edit function
This commit is contained in:
parent
296d8cc1e8
commit
0467d190fe
5 changed files with 234 additions and 42 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue