From 76143d5a51bd448ef03891cb0f23f1b94a4a3761 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 16 Jun 2019 23:04:39 +0200 Subject: [PATCH] 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. --- modules/completion/ivy/autoload/ivy.el | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/modules/completion/ivy/autoload/ivy.el b/modules/completion/ivy/autoload/ivy.el index 6e666327c..dca6d7542 100644 --- a/modules/completion/ivy/autoload/ivy.el +++ b/modules/completion/ivy/autoload/ivy.el @@ -340,11 +340,14 @@ order. (when (> (abs (- end beg)) 1) (let ((query (buffer-substring-no-properties beg end))) ;; Escape characters that are special to ivy searches - (replace-regexp-in-string "[! ]" (lambda (substr) - (if (and (featurep! +fuzzy) - (string= substr " ")) - " " - (concat "\\\\" substr))) + (replace-regexp-in-string "[! |]" (lambda (substr) + (cond ((and (featurep! +fuzzy) + (string= substr " ")) + " ") + ((and (string= substr "|") + (eq engine 'rg)) + "\\\\\\\\|") + ((concat "\\\\" substr)))) (regexp-quote query)))))))) (prompt (format "%s%%s %s"