fix(ivy): counsel-rg dying on non-zero exit code
Monkey-patches counsel-rg to ignore non-zero exit codes. This may have other side effects, but despite it still producing workable resutls, the command will discard all its results if there are any errors while scanning a directory. Ref: abo-abo/swiper#2339 Fix: #3038
This commit is contained in:
parent
f1f72c291a
commit
6ef86098cb
1 changed files with 14 additions and 0 deletions
|
@ -211,6 +211,20 @@ results buffer.")
|
||||||
(when (stringp counsel-rg-base-command)
|
(when (stringp counsel-rg-base-command)
|
||||||
(setq counsel-rg-base-command (split-string 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'
|
;; Integrate with `helpful'
|
||||||
(setq counsel-describe-function-function #'helpful-callable
|
(setq counsel-describe-function-function #'helpful-callable
|
||||||
counsel-describe-variable-function #'helpful-variable
|
counsel-describe-variable-function #'helpful-variable
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue