1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

Really fix off-by-one in erc--get-inserted-msg-bounds

* lisp/erc/erc.el (erc--get-inserted-msg-bounds): Account for
`previous-single-property-change' returning a position adjacent to
that with an actual changed value.  The prior attempt at addressing
this was insufficient.
* test/lisp/erc/erc-tests.el (erc--get-inserted-msg-bounds): New test.
; * test/lisp/erc/resources/base/local-modules/second.eld: Timeout.
; * test/lisp/erc/resources/base/local-modules/third.eld: Timeout.
This commit is contained in:
F. Jason Park 2023-11-03 16:07:20 -07:00
parent 0b5e2ce761
commit fb578ddfb2
4 changed files with 57 additions and 5 deletions

View file

@ -3026,16 +3026,19 @@ stored value. Otherwise, return the stored value."
"Return the bounds of a message in an ERC buffer.
Return ONLY one side when the first arg is `end' or `beg'. With
POINT, search from POINT instead of `point'."
;; TODO add edebug spec.
`(let* ((point ,(or point '(point)))
(at-start-p (get-text-property point 'erc-msg)))
(and-let*
(,@(and (member only '(nil 'beg))
(,@(and (member only '(nil beg 'beg))
'((b (or (and at-start-p point)
(and-let*
((p (previous-single-property-change point
'erc-msg)))
(if (= p (1- point)) p (1- p)))))))
,@(and (member only '(nil 'end))
(if (= p (1- point))
(if (get-text-property p 'erc-msg) p (1- p))
(1- p)))))))
,@(and (member only '(nil end 'end))
'((e (1- (next-single-property-change
(if at-start-p (1+ point) point)
'erc-msg nil erc-insert-marker))))))