Skip to content

Commit

Permalink
Make sure header is visible after recompile
Browse files Browse the repository at this point in the history
  • Loading branch information
dajva committed Apr 3, 2019
1 parent 1b78e53 commit acd8be6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
11 changes: 8 additions & 3 deletions rg-result.el
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ Becomes buffer local in `rg-mode' buffers.")
(define-key map "c" 'rg-rerun-toggle-case)
(define-key map "d" 'rg-rerun-change-dir)
(define-key map "f" 'rg-rerun-change-files)
(define-key map "g" 'recompile)
(define-key map "g" 'rg-recompile)
(define-key map "i" 'rg-rerun-toggle-ignore)
(define-key map "l" 'rg-list-searches)
(define-key map "r" 'rg-rerun-change-regexp)
Expand Down Expand Up @@ -449,6 +449,12 @@ Commands:
rg-search-history)
(rg-maybe-show-header))

(defun rg-recompile ()
"Rerun the current search."
(interactive)
(recompile)
(rg-maybe-show-header))

(defun rg-rerun (&optional no-history)
"Run `recompile' with `compilation-arguments' taken from `rg-cur-search'.
If NO-HISTORY is non nil skip adding the search to the search history."
Expand All @@ -469,8 +475,7 @@ If NO-HISTORY is non nil skip adding the search to the search history."
(unless no-history
(rg-history-push (rg-search-copy rg-cur-search)
rg-search-history))
(recompile)
(rg-maybe-show-header)))
(rg-recompile)))

(defun rg-navigate-file-message (pos limit direction)
"Return position of next 'rg-file-message text property.
Expand Down
6 changes: 3 additions & 3 deletions test/rg.el-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -733,8 +733,8 @@ and ungrouped otherwise."
(should-not (rg-file-message-exist-in-result nil))
(should (rg-file-message-exist-in-result t)))

(ert-deftest rg-integration/recompile ()
"Make sure that `recompile' preserves search parameters."
(ert-deftest rg-integration/rg-recompile ()
"Make sure that `rg-recompile' preserves search parameters."
:tags '(need-rg)
(let ((parent-dir (concat (expand-file-name default-directory) "test/")))
(rg-run "hello" "elisp" (concat parent-dir "data"))
Expand All @@ -752,7 +752,7 @@ and ungrouped otherwise."
(rg-search-files rg-cur-search)
(rg-search-dir rg-cur-search))))
(should (equal '("--text") (rg-search-toggle-flags rg-cur-search)))
(recompile)
(rg-recompile)
(should (rg-wait-for-search-result))
(should (equal
(list "Hello" "all" parent-dir)
Expand Down

0 comments on commit acd8be6

Please sign in to comment.