Skip to content

Commit 3b8bbb0

Browse files
committed
Fix function-from-example when adding function to a different file
1 parent 9f3e735 commit 3b8bbb0

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

clj-refactor.el

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3305,11 +3305,21 @@ warning by customizing `cljr-suppress-no-project-warning'.)"))))
33053305
(defvar cljr--list-fold-function-names-with-index
33063306
'("map-indexed" "keep-indexed"))
33073307

3308+
(defun cljr--chop-prefix (prefix s)
3309+
"Remove PREFIX if it is at the start of S."
3310+
(declare (pure t) (side-effect-free t))
3311+
(let ((pos (length prefix)))
3312+
(if (and (>= (length s) (length prefix))
3313+
(string= prefix (substring s 0 pos)))
3314+
(substring s pos)
3315+
s)))
3316+
33083317
(defun cljr--ns-path (ns-name)
33093318
"Find the file path to the ns named NS-NAME."
33103319
(cider-ensure-connected)
33113320
(cider-ensure-op-supported "ns-path")
3312-
(cider-sync-request:ns-path ns-name))
3321+
(cljr--chop-prefix "file:"
3322+
(cider-sync-request:ns-path ns-name)))
33133323

33143324
;;;###autoload
33153325
(defun cljr-create-fn-from-example ()

0 commit comments

Comments
 (0)