Skip to content

Commit

Permalink
Make sure column numbers are shown in nogroup mode (#113)
Browse files Browse the repository at this point in the history
Apparently the column number visibility was forgotten when
implementing alignment support for grouped mode. Should work now and
also be tested.
  • Loading branch information
dajva committed Jan 13, 2021
1 parent 7055a67 commit c342666
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
5 changes: 3 additions & 2 deletions rg.el
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
16 changes: 16 additions & 0 deletions test/rg.el-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 5 additions & 6 deletions test/test-helper.el
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c342666

Please sign in to comment.