Skip to content

Commit ef300cc

Browse files
benedekfazekasbbatsov
authored andcommitted
[Fix #429] Last occurrence sometimes not replaced for move-to-let (#430)
In the following case: * there are more than one occurrences of an expression * and `move-to-let` is not initiated from the last occurrence * and the actual bound name is longer than the expression being moved to `let` the last expression won't be replaced. The solution: the end of the `let` expression is not cached before calling `clojure--replace-sexps-with-binding`.
1 parent c76435b commit ef300cc

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

clojure-mode-refactor-let-test.el

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,21 @@
164164
(search-backward "(or ")
165165
(clojure--move-to-let-internal "status"))
166166

167+
(def-refactor-test test-move-to-let-name-longer-than-expression
168+
"(defn handle-request
169+
(let []
170+
(println \"body: \" body \", params: \" \", status: \" 5)
171+
{:body body
172+
:status 5}))"
173+
"(defn handle-request
174+
(let [status 5]
175+
(println \"body: \" body \", params: \" \", status: \" status)
176+
{:body body
177+
:status status}))"
178+
(search-backward "5")
179+
(search-backward "5")
180+
(clojure--move-to-let-internal "status"))
181+
167182
;; clojure-emacs/clj-refactor.el#41
168183
(def-refactor-test test-move-to-let-nested-scope
169184
"(defn foo []

0 commit comments

Comments
 (0)