-
-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3552 from jojo2357/refactoring-name
Do not select the extension when refactoring file names
- Loading branch information
Showing
2 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package nl.hannahsten.texifyidea | ||
|
||
import com.intellij.openapi.editor.Editor | ||
import com.intellij.openapi.project.Project | ||
import com.intellij.psi.PsiElement | ||
import com.intellij.psi.PsiFile | ||
import com.intellij.refactoring.rename.RenameDialog | ||
import com.intellij.refactoring.rename.RenamePsiElementProcessor | ||
import com.intellij.refactoring.rename.RenamePsiFileProcessor.PsiFileRenameDialog | ||
|
||
class LatexRenameProcessor : RenamePsiElementProcessor() { | ||
override fun canProcessElement(element: PsiElement): Boolean { | ||
// The reason below is only applicable for files | ||
return when (element) { | ||
is PsiFile -> true | ||
else -> false | ||
} | ||
} | ||
|
||
override fun createRenameDialog(project: Project, element: PsiElement, nameSuggestionContext: PsiElement?, editor: Editor?): RenameDialog { | ||
// We want to not select the extension in the dialog when renaming files, and looking at RenameDialog#createNewNameComponent(), this is done by setting the editor to null | ||
return PsiFileRenameDialog(project, element, nameSuggestionContext, null) | ||
} | ||
} |