Skip to content

Commit

Permalink
ag fix for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
jacktasia committed Feb 29, 2016
1 parent c629d94 commit 9064720
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 7 additions & 4 deletions dumb-jump.el
Original file line number Diff line number Diff line change
Expand Up @@ -535,9 +535,12 @@ denoter file/dir is found or uses dumb-jump-default-profile"
(let* ((resp-lines (s-split "\n" resp))
(parsed (butlast (--map (let ((parts (s-split ":" it)))
;; when ag searches file not dir it will return no path in the resp line so add
(if (= 2 (length parts))
(-concat (list cur-file) parts)
parts))
(cond ((= 2 (length parts))
(-concat (list cur-file) parts))
((= 4 (length parts)) ; windows
(list (concat (car parts) ":" (nth 1 parts)) (nth 2 parts) (nth 3 parts)))
(t
parts)))
resp-lines)))
(results (-mapcat
(lambda (x)
Expand Down Expand Up @@ -641,7 +644,7 @@ denoter file/dir is found or uses dumb-jump-default-profile"
" --search-zip"
"")))
(exclude-args (dumb-jump-arg-joiner "--ignore-dir" (-map (lambda (p) (s-replace proj "" p)) exclude-paths)))
(regex-args (format "'%s'" (s-join "|" filled-regexes))))
(regex-args (format "\"%s\"" (s-join "|" filled-regexes))))
(if (= (length regexes) 0)
""
(dumb-jump-concat-command cmd exclude-args regex-args proj))))
Expand Down
4 changes: 2 additions & 2 deletions test/dumb-jump-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

(ert-deftest dumb-jump-generate-ag-command-no-ctx-test ()
(let ((regexes (dumb-jump-get-contextual-regexes "elisp" nil))
(expected "ag --nocolor --nogroup '\\(defun\\s+tester(?![\\w-])\\s*|\\(defvar\\b\\s*tester\\b\\s?|\\(defcustom\\b\\s*tester\\b\\s?|\\(setq\\b\\s*tester\\b\\s*|\\(tester\\s+|\\(defun\\s*.+\\(?\\s*tester\\b\\s*\\)?' ."))
(expected "ag --nocolor --nogroup \"\\(defun\\s+tester(?![\\w-])\\s*|\\(defvar\\b\\s*tester\\b\\s?|\\(defcustom\\b\\s*tester\\b\\s?|\\(setq\\b\\s*tester\\b\\s*|\\(tester\\s+|\\(defun\\s*.+\\(?\\s*tester\\b\\s*\\)?\" ."))
(should (string= expected (dumb-jump-generate-ag-command "tester" "blah.el" "." regexes "elisp" nil)))))

(ert-deftest dumb-jump-generate-grep-command-no-ctx-funcs-only-test ()
Expand Down Expand Up @@ -97,7 +97,7 @@
(should (= (plist-get test-result ':line) 26))))

(ert-deftest dumb-jump-ag-parse-test ()
(let* ((resp "./dumb-jump.el:22:1:(defun dumb-jump-asdf ()\n./dumb-jump.el:26:1:(defvar dumb-jump-grep-prefix )\n./dumb-jump2.el:28:1:(defvar dumb-jump-grep)")
(let* ((resp "./dumb-jump.el:22:(defun dumb-jump-asdf ()\n./dumb-jump.el:26:(defvar dumb-jump-grep-prefix )\n./dumb-jump2.el:28:1:(defvar dumb-jump-grep)")
(parsed (dumb-jump-parse-ag-response resp "dumb-jump2.el" 28))
(test-result (nth 1 parsed)))
(should (= (plist-get test-result :diff) 2))
Expand Down

0 comments on commit 9064720

Please sign in to comment.