| 1 |
#include "point.h" |
| 2 |
|
| 3 |
void ts_point_edit(TSPoint *point, uint32_t *byte, const TSInputEdit *edit) { |
| 4 |
uint32_t start_byte = *byte; |
| 5 |
TSPoint start_point = *point; |
| 6 |
|
| 7 |
if (start_byte >= edit->old_end_byte) { |
| 8 |
start_byte = edit->new_end_byte + (start_byte - edit->old_end_byte); |
| 9 |
start_point = point_add(edit->new_end_point, point_sub(start_point, edit->old_end_point)); |
| 10 |
} else if (start_byte > edit->start_byte) { |
| 11 |
start_byte = edit->new_end_byte; |
| 12 |
start_point = edit->new_end_point; |
| 13 |
} |
| 14 |
|
| 15 |
*point = start_point; |
| 16 |
*byte = start_byte; |
| 17 |
} |