Escape pipes in selection for rg project searches

Pipes need to be double-escaped, because they're meaningful to both ivy
and ripgrep, and searches conducted on a selection need to be literal.
This commit is contained in:
Henrik Lissner 2019-06-16 23:04:39 +02:00
parent 6be401f1a7
commit 76143d5a51
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -340,11 +340,14 @@ order.
(when (> (abs (- end beg)) 1) (when (> (abs (- end beg)) 1)
(let ((query (buffer-substring-no-properties beg end))) (let ((query (buffer-substring-no-properties beg end)))
;; Escape characters that are special to ivy searches ;; Escape characters that are special to ivy searches
(replace-regexp-in-string "[! ]" (lambda (substr) (replace-regexp-in-string "[! |]" (lambda (substr)
(if (and (featurep! +fuzzy) (cond ((and (featurep! +fuzzy)
(string= substr " ")) (string= substr " "))
" " " ")
(concat "\\\\" substr))) ((and (string= substr "|")
(eq engine 'rg))
"\\\\\\\\|")
((concat "\\\\" substr))))
(regexp-quote query)))))))) (regexp-quote query))))))))
(prompt (prompt
(format "%s%%s %s" (format "%s%%s %s"