Function: projectile-search--rg-parse-line
projectile-search--rg-parse-line is a byte-compiled function defined
in projectile.el.
Signature
(projectile-search--rg-parse-line LINE ROOT)
Documentation
Parse one ripgrep NDJSON LINE into a list of match structs under ROOT.
Returns nil for non-"match" records (begin/end/summary/context) and for records without decodable path or line text. A line with several submatches yields one struct per submatch, in order.
Source Code
;; Defined in ~/.emacs.d/elpa/projectile-20260820.1509/projectile.el
(defun projectile-search--rg-parse-line (line root)
"Parse one ripgrep NDJSON LINE into a list of match structs under ROOT.
Returns nil for non-\"match\" records (begin/end/summary/context) and for
records without decodable path or line text. A line with several
submatches yields one struct per submatch, in order."
(condition-case nil
(let ((obj (json-parse-string line)))
(when (equal (gethash "type" obj) "match")
(let* ((data (gethash "data" obj))
(path (projectile-search--rg-json-get data "path" "text"))
(line-no (projectile-search--rg-json-get data "line_number"))
(text (projectile-search--rg-json-get data "lines" "text"))
(subs (gethash "submatches" data))
(context (and (stringp text)
(replace-regexp-in-string "\r?\n\\'" "" text)))
(result nil))
(when (and (stringp path) (integerp line-no) (stringp text) subs)
(let ((file (expand-file-name path root)))
(dotimes (i (length subs))
(let* ((sub (aref subs i))
(start (gethash "start" sub))
(mstr (projectile-search--rg-json-get
sub "match" "text")))
(when (stringp mstr)
(push (projectile-replace--match-create
:file file :buffer nil :tick nil
:line line-no
:column (projectile-search--rg-byte->char-column
text start)
:beg nil :end nil
:string mstr :match-data nil :groups nil
:context context :enabled t)
result))))))
(nreverse result))))
(error nil)))