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)))
|
||||
(when properties
|
||||
(tp-put object beg end properties))
|
||||
;; Advance by at least 1 to avoid infinite loop on empty match
|
||||
(setq pos (max (1+ beg) end))))
|
||||
;; Advance position: for zero-width match, advance by 1 to avoid infinite loop
|
||||
(setq pos (if (= beg end) (1+ beg) end))))
|
||||
object))
|
||||
;; Buffer or nil (current buffer)
|
||||
(t
|
||||
@ -678,8 +678,8 @@ Returns:
|
||||
(end (match-end 0)))
|
||||
(when properties
|
||||
(tp-put object beg end properties))
|
||||
;; Advance by at least 1 to avoid infinite loop on zero-width match
|
||||
(setq pos (max (1+ beg) end))))
|
||||
;; Advance position: for zero-width match, advance by 1 to avoid infinite loop
|
||||
(setq pos (if (= beg end) (1+ beg) end))))
|
||||
object))
|
||||
;; Buffer or nil (current buffer)
|
||||
(t
|
||||
|
||||
Loading…
Reference in New Issue
Block a user