Skip to content

Commit 5f00a16

Browse files
committed
fix: creating all files as luau
1 parent f9fc71b commit 5f00a16

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/main/kotlin/com/github/aleksandrsl/intellijluau/template/LuauCreateFromTemplateHandler.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.github.aleksandrsl.intellijluau.template
22

3+
import com.github.aleksandrsl.intellijluau.LuauFileType
34
import com.github.aleksandrsl.intellijluau.settings.ProjectSettingsState
45
import com.intellij.ide.fileTemplates.DefaultCreateFromTemplateHandler
56
import com.intellij.ide.fileTemplates.FileTemplate
@@ -16,6 +17,9 @@ class LuauCreateFromTemplateHandler : DefaultCreateFromTemplateHandler() {
1617
templateText: String,
1718
props: Map<String?, Any?>
1819
): PsiElement {
20+
if (!template.isTemplateOfType(LuauFileType)) {
21+
return super.createFromTemplate(project, directory, fileName, template, templateText, props)
22+
}
1923
// I want a different extension based on the settings (Legacy projects may use .lua extension).
2024
// Having a separate template is weird given that I may have different templates, but the content is the same. So the best way is to use the correct extension.
2125
// I tried cloning a template and setting the correct extension for it, but it doesn't work, since the value is coming from an internal object I don't have access to.
@@ -30,6 +34,9 @@ class LuauCreateFromTemplateHandler : DefaultCreateFromTemplateHandler() {
3034

3135
// See comment in createFromTemplate
3236
override fun checkAppendExtension(fileName: String?, template: FileTemplate): String? {
37+
if (!template.isTemplateOfType(LuauFileType)) {
38+
return super.checkAppendExtension(fileName, template)
39+
}
3340
return fileName
3441
}
3542
}

0 commit comments

Comments
 (0)