Description
Problem Description
Using the delete-between-points
function on text has unexpected effects when there are multiple points in the buffer (particularly on separate lines).
- Points on lines after the deleted region do not have their
linum
field updated - If a point is in a region that is deleted, its
line-string
is not updated.
Demonstrations
I wrote a simple function that creates 3 points, each a copy of (current-point)
. The line number and line string for point b
are before the text between a
and c
is deleted, and again after. The function is called at the start of a test buffer.
(defun test (b-offset c-offset)
(lem:with-point ((a (lem:current-point))
(c (lem:current-point))
(b (lem:current-point)))
(lem:line-offset b b-offset)
(lem:line-offset c c-offset)
(lem:insert-string b "[b1]")
(lem:message "b line before: ~A : ~A" (lem:line-number-at-point b) (lem:line-string b))
(lem:delete-between-points a c)
(lem:insert-string b "[b2]")
(lem:message "b line after: ~A : ~A" (lem:line-number-at-point b) (lem:line-string b))))
Example 1: b
is outside the deleted range
If b
is outside the deleted range (and after c
), b
's linum
is not updated after the text between a
and c
is deleted.
Original Buffer Text
1 filler
2 text
3 to
4 show
5 as
6 an
7 example
Function Call
b
will be moved down 5, c
will be moved down 4. Thus, b is outside the deleted range.
(test 5 4)
Output to Message Buffer
b line before: 6 : [b1]an
b line after: 6 : [b2][b1]an
Buffer Text after function call
1 as
2 [b2][b1]an
3 example
Example 2: b
is inside the deleted range
if b
is inside the deleted range, then the line-string
inside b
appears to no longer reference a line in the buffer. b
's linum
also is not updated.
Function Call
b
will be moved down 4, c
will be moved down 5. Thus, b is inside the deleted range.
The initial buffer text is the same as in example 1
(test 4 5)
Output to Message Buffer
b line before: 5 : [b1]as
b line after: 5 : [b2]
Buffer text after function call
1 an
2 example