Skip to content

Commit 8c16ee0

Browse files
committed
Fix Rename feature not being available for some cases
1 parent d5db30c commit 8c16ee0

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

CHANGELOG.md

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

55
- Add shortcuts to backward slurp and barf.
66
- Add shortcut documentation to all features, check the features doc page.
7+
- Fix Rename feature not being available for some cases.
78

89
## 1.14.5
910

src/main/clojure/com/github/clojure_lsp/intellij/extension/rename.clj

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,20 @@
1212
[com.intellij.openapi.project Project]
1313
[com.intellij.openapi.ui Messages NonEmptyInputValidator]
1414
[com.intellij.openapi.util TextRange]
15-
[com.intellij.psi PsiFile]
15+
[com.intellij.psi PsiDocumentManager PsiFile]
1616
[com.intellij.refactoring.rename PsiElementRenameHandler]))
1717

1818
(set! *warn-on-reflection* true)
1919

2020
(defn -isAvailableOnDataContext [_ ^DataContext data-context]
2121
(boolean
22-
(and (.getData data-context CommonDataKeys/EDITOR)
23-
(.getData data-context CommonDataKeys/PSI_FILE)
24-
(let [element (PsiElementRenameHandler/getElement data-context)]
25-
(instance? PsiFile element)))))
22+
(when-let [element (or (and (.getData data-context CommonDataKeys/PSI_FILE)
23+
(PsiElementRenameHandler/getElement data-context))
24+
(and (.getData data-context CommonDataKeys/PROJECT)
25+
(.getData data-context CommonDataKeys/EDITOR)
26+
(.getPsiFile (PsiDocumentManager/getInstance (.getData data-context CommonDataKeys/PROJECT))
27+
(.getDocument ^Editor (.getData data-context CommonDataKeys/EDITOR)))))]
28+
(instance? PsiFile element))))
2629

2730
(defn -isRenaming [this data-context]
2831
(-isAvailableOnDataContext this data-context))

0 commit comments

Comments
 (0)