Skip to content

Commit 8ab9ae1

Browse files
author
Ryan Smith
committed
Clean symbol before doing look up
If you attempt to run `cider-jump-to-var` to find the definition of an atom dereferenced with `@`, cider can't find the source location. If you remove the `@` cider has no issues finding the location. This allows for cleaning non-variable components out of a symbol before doing the look up to prevent this issue.
1 parent 32c2979 commit 8ab9ae1

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

cider-interaction.el

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,13 +492,22 @@ When invoked with a prefix ARG the command doesn't prompt for confirmation."
492492
(bounds-of-thing-at-point 'sexp)))
493493
(bounds-of-thing-at-point 'sexp)))
494494

495+
(defun cider--clean-symbol (symbol)
496+
"Return SYMBOL cleaned so a dictionary match can be found."
497+
(if (string-equal symbol "")
498+
symbol
499+
(let* ((symbol (if (string-equal (substring symbol 0 1) "@")
500+
(substring symbol 1)
501+
symbol)))
502+
symbol)))
503+
495504
;; FIXME: This doesn't have properly at the beginning of the REPL prompt
496505
(defun cider-symbol-at-point ()
497506
"Return the name of the symbol at point, otherwise nil."
498507
(let ((str (substring-no-properties (or (thing-at-point 'symbol) ""))))
499508
(if (equal str (concat (cider-current-ns) "> "))
500509
""
501-
str)))
510+
(cider--clean-symbol str))))
502511

503512
(defun cider-sexp-at-point ()
504513
"Return the sexp at point as a string, otherwise nil."

test/cider-tests.el

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,10 @@
532532
(cider-current-ns () "user"))
533533
(should (string= (cider-symbol-at-point) ""))))
534534

535+
(ert-deftest cider-symbol-at-point-deref ()
536+
(noflet ((thing-at-point (thing) "@user"))
537+
(should (string= (cider-symbol-at-point) "user"))))
538+
535539
(ert-deftest test-cider--url-to-file ()
536540
(should (equal "/space test" (cider--url-to-file "file:/space%20test")))
537541
(should (equal "C:/space test" (cider--url-to-file "file:/C:/space%20test"))))

0 commit comments

Comments
 (0)