diff --git a/src/main/java/com/tang/intellij/lua/debugger/LuaDebuggerEvaluator.kt b/src/main/java/com/tang/intellij/lua/debugger/LuaDebuggerEvaluator.kt index cdd38b666..2895a3119 100644 --- a/src/main/java/com/tang/intellij/lua/debugger/LuaDebuggerEvaluator.kt +++ b/src/main/java/com/tang/intellij/lua/debugger/LuaDebuggerEvaluator.kt @@ -34,33 +34,31 @@ import com.tang.intellij.lua.psi.* abstract class LuaDebuggerEvaluator : XDebuggerEvaluator() { override fun getExpressionRangeAtOffset(project: Project, document: Document, offset: Int, sideEffectsAllowed: Boolean): TextRange? { var currentRange: TextRange? = null - PsiDocumentManager.getInstance(project).commitAndRunReadAction { - try { - val file = PsiDocumentManager.getInstance(project).getPsiFile(document) ?: return@commitAndRunReadAction - if (currentRange == null) { - val ele = file.findElementAt(offset) - if (ele != null && ele.node.elementType == LuaTypes.ID) { - val parent = ele.parent - when (parent) { - is LuaFuncDef, - is LuaLocalFuncDef -> currentRange = ele.textRange - is LuaClassMethodName, - is PsiNameIdentifierOwner -> currentRange = parent.textRange - } + try { + val file = PsiDocumentManager.getInstance(project).getPsiFile(document) ?: return null + if (currentRange == null) { + val ele = file.findElementAt(offset) + if (ele != null && ele.node.elementType == LuaTypes.ID) { + val parent = ele.parent + when (parent) { + is LuaFuncDef, + is LuaLocalFuncDef -> currentRange = ele.textRange + is LuaClassMethodName, + is PsiNameIdentifierOwner -> currentRange = parent.textRange } } + } - if (currentRange == null) { - val expr = PsiTreeUtil.findElementOfClassAtOffset(file, offset, LuaExpr::class.java, false) - currentRange = when (expr) { - is LuaCallExpr, - is LuaClosureExpr, - is LuaLiteralExpr -> null - else -> expr?.textRange - } + if (currentRange == null) { + val expr = PsiTreeUtil.findElementOfClassAtOffset(file, offset, LuaExpr::class.java, false) + currentRange = when (expr) { + is LuaCallExpr, + is LuaClosureExpr, + is LuaLiteralExpr -> null + else -> expr?.textRange } - } catch (ignored: IndexNotReadyException) { } + } catch (ignored: IndexNotReadyException) { } return currentRange } diff --git a/src/main/java/com/tang/intellij/lua/editor/formatter/LuaCodeStyleSettingsProvider.kt b/src/main/java/com/tang/intellij/lua/editor/formatter/LuaCodeStyleSettingsProvider.kt index 084f81972..b8f1fa022 100644 --- a/src/main/java/com/tang/intellij/lua/editor/formatter/LuaCodeStyleSettingsProvider.kt +++ b/src/main/java/com/tang/intellij/lua/editor/formatter/LuaCodeStyleSettingsProvider.kt @@ -54,6 +54,8 @@ class LuaCodeStyleSettingsProvider : CodeStyleSettingsProvider() { } } + override fun getLanguage() = LuaLanguage.INSTANCE + override fun getConfigurableDisplayName() = LuaLanguage.INSTANCE.displayName override fun createCustomSettings(settings: CodeStyleSettings): CustomCodeStyleSettings {