Skip to content

Commit 9f508bb

Browse files
authored
Merge pull request #439 from anthonygalea/master
[Fix #402] Do not alter strings when using `cljr-stop-referring`.
2 parents 3edc678 + a05a268 commit 9f508bb

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Unreleased
44

5+
- [#402](https://github.com/clojure-emacs/clj-refactor.el/issues/402) cljr-stop-referring: do not alter strings.
56
- [#380](https://github.com/clojure-emacs/clj-refactor.el/issues/380) clean-ns: fix FileNotFoundException, by trying both the absolute path and the path relative to the project root. This requires a new refactor-nrepl, old versions will only check the absolute path.
67

78
## 2.4.0 (2018-08-26)

clj-refactor.el

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,9 +1328,12 @@ See: https://github.com/clojure-emacs/clj-refactor.el/wiki/cljr-stop-referring"
13281328
(paredit-forward)
13291329
(let ((case-fold-search nil))
13301330
(while (re-search-forward (regexp-opt symbols 'symbols) nil t)
1331-
(paredit-backward)
1332-
(insert ns "/")
1333-
(paredit-forward)))))
1331+
(when (save-excursion
1332+
(paredit-backward-up)
1333+
(not (looking-at "\"")))
1334+
(paredit-backward)
1335+
(insert ns "/")
1336+
(paredit-forward))))))
13341337

13351338
(defun cljr--insert-with-proper-whitespace (forms)
13361339
(open-line 2)

features/stop-refering.feature

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,25 @@ Feature: Stop referring
109109
(+ (lib/a 1) (lib/b 2))
110110
(+ (A 1) (B 2))
111111
"""
112+
113+
Scenario: With string literals, #402
114+
When I insert:
115+
"""
116+
(ns cljr.core
117+
(:require [my.lib :refer [a foo]]))
118+
119+
(def x "Hello foo")
120+
121+
(+ (a 1) (foo 2))
122+
"""
123+
And I place the cursor before "my.lib"
124+
And I press "C-! sr"
125+
Then I should see:
126+
"""
127+
(ns cljr.core
128+
(:require [my.lib]))
129+
130+
(def x "Hello foo")
131+
132+
(+ (my.lib/a 1) (my.lib/foo 2))
133+
"""

0 commit comments

Comments
 (0)