diff --git a/modules/completion/ivy/config.el b/modules/completion/ivy/config.el index e537abf81..3372ab758 100644 --- a/modules/completion/ivy/config.el +++ b/modules/completion/ivy/config.el @@ -211,6 +211,20 @@ results buffer.") (when (stringp counsel-rg-base-command) (setq counsel-rg-base-command (split-string counsel-rg-base-command))) + ;; REVIEW: See abo-abo/swiper#2339. + (defadvice! +counsel-rg-suppress-error-code-a (fn &rest args) + "Ripgrep returns a non-zero exit code if it encounters any trouble (e.g. you +don't have the needed permissions for a couple files/directories in a project). +Even if rg continues to produce workable results, that non-zero exit code causes +counsel-rg to discard the rest of the output to display an error. + +This advice suppresses the error code, so you can still operate on whatever +workable results ripgrep produces, despite the error." + :around #'counsel-rg + (letf! (defun process-exit-status (code) + (funcall process-exit-status (if (= code 2) 0 code))) + (apply fn args))) + ;; Integrate with `helpful' (setq counsel-describe-function-function #'helpful-callable counsel-describe-variable-function #'helpful-variable