diff options
| author | Richard M. Stallman | 1998-03-02 02:41:28 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1998-03-02 02:41:28 +0000 |
| commit | 75167cd4e42834950627cc026fff7b58fafa08ef (patch) | |
| tree | a5c6f5092f0b66422944384950179859d3dbbf06 /src/intervals.c | |
| parent | d80f4cc71caa321a933fdcda298425c914cdeb41 (diff) | |
| download | emacs-75167cd4e42834950627cc026fff7b58fafa08ef.tar.gz emacs-75167cd4e42834950627cc026fff7b58fafa08ef.zip | |
(update_interval): Properly update `position' field of used intervals.
Diffstat (limited to 'src/intervals.c')
| -rw-r--r-- | src/intervals.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/intervals.c b/src/intervals.c index f52e6ea4727..c5dad670926 100644 --- a/src/intervals.c +++ b/src/intervals.c | |||
| @@ -672,7 +672,8 @@ previous_interval (interval) | |||
| 672 | } | 672 | } |
| 673 | 673 | ||
| 674 | /* Find the interval containing POS given some non-NULL INTERVAL | 674 | /* Find the interval containing POS given some non-NULL INTERVAL |
| 675 | in the same tree. */ | 675 | in the same tree. Note that we need to update interval->position |
| 676 | if we go down the tree. */ | ||
| 676 | INTERVAL | 677 | INTERVAL |
| 677 | update_interval (i, pos) | 678 | update_interval (i, pos) |
| 678 | register INTERVAL i; | 679 | register INTERVAL i; |
| @@ -686,22 +687,31 @@ update_interval (i, pos) | |||
| 686 | if (pos < i->position) | 687 | if (pos < i->position) |
| 687 | { | 688 | { |
| 688 | /* Move left. */ | 689 | /* Move left. */ |
| 689 | if (pos >= i->position - TOTAL_LENGTH (i->left)) | 690 | if (pos >= i->position - TOTAL_LENGTH (i->left)) |
| 690 | i = i->left; /* Move to the left child */ | 691 | { |
| 692 | i->left->position = i->position - TOTAL_LENGTH (i->left) | ||
| 693 | + LEFT_TOTAL_LENGTH (i->left); | ||
| 694 | i = i->left; /* Move to the left child */ | ||
| 695 | } | ||
| 691 | else if (NULL_PARENT (i)) | 696 | else if (NULL_PARENT (i)) |
| 692 | error ("Point before start of properties"); | 697 | error ("Point before start of properties"); |
| 693 | else i = i->parent; | 698 | else |
| 699 | i = i->parent; | ||
| 694 | continue; | 700 | continue; |
| 695 | } | 701 | } |
| 696 | else if (pos >= INTERVAL_LAST_POS (i)) | 702 | else if (pos >= INTERVAL_LAST_POS (i)) |
| 697 | { | 703 | { |
| 698 | /* Move right. */ | 704 | /* Move right. */ |
| 699 | if (pos < INTERVAL_LAST_POS (i) + TOTAL_LENGTH (i->right)) | 705 | if (pos < INTERVAL_LAST_POS (i) + TOTAL_LENGTH (i->right)) |
| 700 | i = i->right; /* Move to the right child */ | 706 | { |
| 707 | i->right->position = INTERVAL_LAST_POS (i) + | ||
| 708 | LEFT_TOTAL_LENGTH (i->right); | ||
| 709 | i = i->right; /* Move to the right child */ | ||
| 710 | } | ||
| 701 | else if (NULL_PARENT (i)) | 711 | else if (NULL_PARENT (i)) |
| 702 | error ("Point after end of properties"); | 712 | error ("Point after end of properties"); |
| 703 | else | 713 | else |
| 704 | i = i->parent; | 714 | i = i->parent; |
| 705 | continue; | 715 | continue; |
| 706 | } | 716 | } |
| 707 | else | 717 | else |