Skip to content

Commit

Permalink
if using quick-look then always use the popup, closes #249 (#260)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacktasia authored Feb 13, 2019
1 parent 190b164 commit 82c3c40
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
14 changes: 8 additions & 6 deletions dumb-jump.el
Original file line number Diff line number Diff line change
Expand Up @@ -1671,9 +1671,7 @@ Ignore PROJ"
(defun dumb-jump-prompt-user-for-choice (proj results)
"Put a PROJ's list of RESULTS in a 'popup-menu' (or helm/ivy)
for user to select. Filters PROJ path from files for display."
(let* ((choices (-map (lambda (result)
(dumb-jump--format-result proj result))
results)))
(let ((choices (--map (dumb-jump--format-result proj it) results)))
(cond
((and (eq dumb-jump-selector 'ivy) (fboundp 'ivy-read))
(funcall dumb-jump-ivy-jump-to-selected-function results choices proj))
Expand Down Expand Up @@ -2089,9 +2087,13 @@ PREFER-EXTERNAL will sort current file last."
(dumb-jump-message
"-----\nDUMB JUMP DEBUG `dumb-jump-handle-results` START\n----- \n\nlook for: \n\t%s\n\ntype: \n\t%s \n\njump? \n\t%s \n\nmatches: \n\t%s \n\nresults: \n\t%s \n\nprefer external: \n\t%s\n\nmatch-cur-file-front: \n\t%s\n\nproj-root: \n\t%s\n\ncur-file: \n\t%s\n\nreal-cur-file: \n\t%s \n\n-----\nDUMB JUMP DEBUG `dumb-jump-handle-results` END\n-----\n"
look-for ctx-type var-to-jump (pp-to-string match-cur-file-front) (pp-to-string results) prefer-external match-cur-file-front proj-root cur-file rel-cur-file))
(if do-var-jump
(dumb-jump-result-follow var-to-jump use-tooltip proj-root)
(dumb-jump-prompt-user-for-choice proj-root match-cur-file-front))))
(cond
(use-tooltip ;; quick-look mode
(popup-menu* (--map (dumb-jump--format-result proj-root it) results)))
(do-var-jump
(dumb-jump-result-follow var-to-jump use-tooltip proj-root))
(t
(dumb-jump-prompt-user-for-choice proj-root match-cur-file-front)))))

(defun dumb-jump-read-config (root config-file)
"Load and return options (exclusions, inclusions, etc).
Expand Down
8 changes: 8 additions & 0 deletions test/dumb-jump-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -1232,6 +1232,14 @@
(mock (dumb-jump-prompt-user-for-choice "/code/redux" *))
(dumb-jump-handle-results results "relfile.js" "/code/redux" "" "isNow" nil nil))))

(ert-deftest dumb-jump-handle-results-non-aggressively-quick-look-test ()
(let ((dumb-jump-aggressive nil)
(results '((:path "relfile.js" :line 62 :context "var isNow = true" :diff 7 :target "isNow")
(:path "src/absfile.js" :line 69 :context "isNow = false" :diff 0 :target "isNow"))))
(with-mock
(mock (popup-menu* '("relfile.js:62: var isNow = true" "src/absfile.js:69: isNow = false")) :times 1)
(dumb-jump-handle-results results "relfile.js" "/code/redux" "" "isNow" t nil))))

;; Make sure it jumps when there's only one possiblity in non-aggressive mode.
(ert-deftest dumb-jump-handle-results-non-aggressive-do-jump-test ()
(let ((dumb-jump-aggressive nil)
Expand Down

0 comments on commit 82c3c40

Please sign in to comment.