Repository: clojure-lsp/clojure-lsp (clojure)

Issue:
Renaming keywords adds extra colons
Renaming `:foo` to `:bar` will actually rename it to `::bar` and renaming `::foo` to `::bar` will rename it to `::::bar`

Pull request description:
This PR fix #19 by striping the leading colons from input before assembling final `newText`.

Patch:
diff --git a/src/clojure_lsp/handlers.clj b/src/clojure_lsp/handlers.clj
index 80739cb93..e745c54fe 100644
--- a/src/clojure_lsp/handlers.clj
+++ b/src/clojure_lsp/handlers.clj
@@ -309,8 +309,8 @@
     (when-not (contains? tags :norename)
       (let [[_ cursor-ns _] (parser/ident-split cursor-str)
             replacement (if cursor-ns
-                          (string/replace new-name (re-pattern (str "^" cursor-ns "/")) "")
-                          new-name)
+                          (string/replace new-name (re-pattern (str "^:{0,2}" cursor-ns "/")) "")
+                          (string/replace new-name #"^:{0,2}" ""))
             changes (->> (for [[doc-id usages] file-envs
                                :let [version (get-in @db/db [:documents doc-id :v] 0)]
                                {u-sym :sym u-str :str :as usage} usages


Test patch:
diff --git a/test/clojure_lsp/handlers_test.clj b/test/clojure_lsp/handlers_test.clj
index ec198eda9..f7b9dd98b 100644
--- a/test/clojure_lsp/handlers_test.clj
+++ b/test/clojure_lsp/handlers_test.clj
@@ -7,12 +7,16 @@
 
 (deftest test-rename
   (reset! db/db {:file-envs
-                 {"file://a.clj" (parser/find-references "(ns a) (def bar)" :clj)
-                  "file://b.clj" (parser/find-references "(ns b (:require a)) (def x a/bar)" :clj)}})
+                 {"file://a.clj" (parser/find-references "(ns a) (def bar ::bar)" :clj)
+                  "file://b.clj" (parser/find-references "(ns b (:require a)) (def x a/bar) :a/bar" :clj) }})
   (testing "rename on symbol without namespace"
     (is (= "foo" (get-in (handlers/rename "file://a.clj" 1 13 "foo")
                          [:changes "file://a.clj" 0 :new-text])))
     (is (= "a/foo" (get-in (handlers/rename "file://a.clj" 1 13 "foo")
+                           [:changes "file://b.clj" 0 :new-text])))
+    (is (= "::foo" (get-in (handlers/rename "file://a.clj" 1 17 ":foo")
+                         [:changes "file://a.clj" 0 :new-text])))
+    (is (= ":a/foo" (get-in (handlers/rename "file://a.clj" 1 17 ":foo")
                            [:changes "file://b.clj" 0 :new-text]))))
   (testing "rename on symbol with namespace adds existing namespace"
     (is (= "foo" (get-in (handlers/rename "file://b.clj" 1 30 "foo")