Improve zero-width match handling in tp-match and tp-regexp
Co-authored-by: Kinneyzhang <38454496+Kinneyzhang@users.noreply.github.com>
This commit is contained in:
parent
a34c1ee625
commit
519a5ec42f
8
tp.el
8
tp.el
@ -614,8 +614,8 @@ Returns:
|
|||||||
(end (match-end 0)))
|
(end (match-end 0)))
|
||||||
(when properties
|
(when properties
|
||||||
(tp-put object beg end properties))
|
(tp-put object beg end properties))
|
||||||
;; Advance by at least 1 to avoid infinite loop on empty match
|
;; Advance position: for zero-width match, advance by 1 to avoid infinite loop
|
||||||
(setq pos (max (1+ beg) end))))
|
(setq pos (if (= beg end) (1+ beg) end))))
|
||||||
object))
|
object))
|
||||||
;; Buffer or nil (current buffer)
|
;; Buffer or nil (current buffer)
|
||||||
(t
|
(t
|
||||||
@ -678,8 +678,8 @@ Returns:
|
|||||||
(end (match-end 0)))
|
(end (match-end 0)))
|
||||||
(when properties
|
(when properties
|
||||||
(tp-put object beg end properties))
|
(tp-put object beg end properties))
|
||||||
;; Advance by at least 1 to avoid infinite loop on zero-width match
|
;; Advance position: for zero-width match, advance by 1 to avoid infinite loop
|
||||||
(setq pos (max (1+ beg) end))))
|
(setq pos (if (= beg end) (1+ beg) end))))
|
||||||
object))
|
object))
|
||||||
;; Buffer or nil (current buffer)
|
;; Buffer or nil (current buffer)
|
||||||
(t
|
(t
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user