diff --git a/src/main/java/com/tang/intellij/lua/braces/LuaBraceMatcher.kt b/src/main/java/com/tang/intellij/lua/braces/LuaBraceMatcher.kt index 98dc729d4..44fde08ed 100644 --- a/src/main/java/com/tang/intellij/lua/braces/LuaBraceMatcher.kt +++ b/src/main/java/com/tang/intellij/lua/braces/LuaBraceMatcher.kt @@ -37,8 +37,8 @@ class LuaBraceMatcher : PairedBraceMatcher { return true } - override fun getCodeConstructStart(psiFile: PsiFile, i: Int): Int { - return i + override fun getCodeConstructStart(psiFile: PsiFile, openingOffset: Int): Int { + return openingOffset } companion object { diff --git a/src/main/java/com/tang/intellij/lua/editor/LuaEnterAfterUnmatchedBraceHandler.kt b/src/main/java/com/tang/intellij/lua/editor/LuaEnterAfterUnmatchedBraceHandler.kt index b4203ea5e..cd206c358 100644 --- a/src/main/java/com/tang/intellij/lua/editor/LuaEnterAfterUnmatchedBraceHandler.kt +++ b/src/main/java/com/tang/intellij/lua/editor/LuaEnterAfterUnmatchedBraceHandler.kt @@ -67,6 +67,7 @@ class LuaEnterAfterUnmatchedBraceHandler : EnterHandlerDelegate { var shouldClose = false var range: PsiElement? = null var cur: PsiElement = lElement + val endTypeAtCaret = getEnd(cur.parent.node.elementType) while (true) { val searched = cur.parent if (searched == null || searched is PsiFile) break @@ -86,9 +87,9 @@ class LuaEnterAfterUnmatchedBraceHandler : EnterHandlerDelegate { val endType = getEnd(range.node.elementType) val document = editor.document if (rElement !is PsiWhiteSpace) - document.insertString(caretOffset, "$endType ") + document.insertString(caretOffset, "$endTypeAtCaret ") else - document.insertString(caretOffset, "$endType") + document.insertString(caretOffset, "$endTypeAtCaret") editorActionHandler?.execute(editor, editor.caretModel.currentCaret, dataContext) val project = lElement.project