Skip to content

Commit a34e0d4

Browse files
committed
Don't forget offset line in cider-stacktrace-navigate.
1 parent b788a8d commit a34e0d4

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

cider-interaction.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ When called interactively, this operates on point, or falls back to a prompt."
696696
(-if-let* ((ns (cadr (assoc "ns" info)))
697697
(name (cadr (assoc "name" info)))
698698
(buffer (cider-find-buffer ns))
699-
(pos (cider-locate-def buffer name)))
699+
(pos (cider-locate-def name buffer)))
700700
(cider-jump-to buffer pos)
701701
(message "No source available for %s" var)))
702702
(message "Symbol %s not resolved" var)))

cider-stacktrace.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ it wraps to 0."
412412
(-if-let* ((ns (cadr (assoc "ns" info)))
413413
(name (cadr (assoc "name" info)))
414414
(buffer (cider-find-buffer ns))
415-
(pos (cider-locate-def buffer name)))
415+
(pos (cider-locate-def name buffer line)))
416416
(cider-jump-to buffer pos)
417417
(message "No source info")))))
418418

cider-util.el

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,17 +152,21 @@ Unless you specify a BUFFER it will default to the current one."
152152
(--filter (equal ns (with-current-buffer it (clojure-find-ns))))
153153
(car)))
154154

155-
(defun cider-locate-def (buffer name)
156-
"Locate in BUFFER the definition of var NAME.
157-
This is a regexp search and currently works only for top level clojure
158-
forms that start with '(def'."
155+
(defun cider-locate-def (name buffer &optional offset-lines)
156+
"Locate the definition of var NAME in BUFFER.
157+
When OFFSET-LINES is non-nil, adjust the returned position by this many
158+
lines. This is a regexp search and currently works only for top level
159+
clojure forms that start with '(def'."
159160
(with-current-buffer buffer
160161
(save-restriction
161162
(widen)
162163
(goto-char (point-min))
163164
(re-search-forward (format "(def.* %s\\( \\|$\\)" name)
164165
nil 'no-error)
165-
(goto-char (match-beginning 0)))))
166+
(goto-char (match-beginning 0))
167+
(when offset-lines
168+
(forward-line (1- offset-lines)))
169+
(point))))
166170

167171
;;; Strings
168172

0 commit comments

Comments
 (0)