From c34266646951618af916684e954c33a9b1f86085 Mon Sep 17 00:00:00 2001 From: David Landell Date: Wed, 13 Jan 2021 16:59:46 +0100 Subject: [PATCH] Make sure column numbers are shown in nogroup mode (#113) Apparently the column number visibility was forgotten when implementing alignment support for grouped mode. Should work now and also be tested. --- rg.el | 5 +++-- test/rg.el-test.el | 16 ++++++++++++++++ test/test-helper.el | 11 +++++------ 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/rg.el b/rg.el index db92358..ca61e64 100644 --- a/rg.el +++ b/rg.el @@ -153,8 +153,7 @@ line flags to use.") "--colors=path:fg:magenta" "--colors=line:fg:green" "--colors=column:none" - "-n" - "--column")) + "-n")) (defconst rg-internal-type-aliases '(("all" . "all defined type aliases") ; rg --type=all @@ -222,6 +221,8 @@ are command line flags to use for the search." (let ((command-line (append rg-required-command-line-flags + (when (or rg-show-columns rg-group-result) + (list "--column")) (rg-build-type-add-args) (if (functionp rg-command-line-flags) (funcall rg-command-line-flags) diff --git a/test/rg.el-test.el b/test/rg.el-test.el index a718856..48dbe03 100644 --- a/test/rg.el-test.el +++ b/test/rg.el-test.el @@ -625,6 +625,22 @@ method. " (rg-toggle-command-hiding) (should (get-text-property (point) 'display))))) +(ert-deftest rg-integration/nogroup-show-columns () + "Test that column numbers are shown in no group mode if enabled." + :tags '(need-rg) + (let ((rg-group-result nil) + (rg-show-columns t)) + (rg-test-with-first-error "hello" + (should (looking-at ".*:[0-9]:[0-9]"))))) + +(ert-deftest rg-integration/nogroup-hide-columns () + "Test that column numbers are hidden in no group mode if disabled." + :tags '(need-rg) + (let ((rg-group-result nil) + (rg-show-columns nil)) + (rg-test-with-first-error "hello" + (should (looking-at ".*:[0-9]:[^0-9]"))))) + (ert-deftest rg-integration/positions-line-only () "Test line position format without alignment." :tags '(need-rg) diff --git a/test/test-helper.el b/test/test-helper.el index c30bc12..9d5a07d 100644 --- a/test/test-helper.el +++ b/test/test-helper.el @@ -128,12 +128,11 @@ SEARCH can either be a search string or a form invocating `rg-run'." (defmacro rg-test-with-first-error (search &rest body) "Run search and put point at start of first error line when running BODY." (declare (indent 0) (debug t)) - `(let ((rg-group-result t)) - (rg-test-with-fontified-buffer ,search - (compilation-next-error 1) - (should-not (eq (point) (point-max))) - (beginning-of-line) - ,@body))) + `(rg-test-with-fontified-buffer ,search + (compilation-next-error 1) + (should-not (eq (point) (point-max))) + (beginning-of-line) + ,@body)) (defun simulate-rg-run (pattern files dir) (setq-default rg-cur-search