diff --git a/editor/src/commonMain/kotlin/editor/basic/CharEventHandlers.kt b/editor/src/commonMain/kotlin/editor/basic/CharEventHandlers.kt index a682f31..637f3a9 100644 --- a/editor/src/commonMain/kotlin/editor/basic/CharEventHandlers.kt +++ b/editor/src/commonMain/kotlin/editor/basic/CharEventHandlers.kt @@ -108,8 +108,13 @@ public inline fun closingBrack textFieldState.lineOffsets[finishLine]?.let { it + oldOffsetStart } ?: textFieldState.offsets[finishLine].last() if (position.column > (textFieldState.lineOffsets[finishLine] ?: Int.MAX_VALUE)) return@f null val token = textFieldState.tokens - .lastOrNull { it is Bracket && it.scopeChange == ScopeChange.OpensScope && it !in matchedBrackets } - ?.takeIf { it.text == openingBracket } + .lastOrNull { + it is Bracket && textFieldState.tokenOffsets[it]!!.last < textFieldState.selection.min && + it.scopeChange == ScopeChange.OpensScope && it.text == openingBracket && + matchedBrackets[it].let { paired -> + paired == null || textFieldState.tokenOffsets[paired as T]!!.first >= textFieldState.selection.max + } + } ?: return@f null val openTokenStartPosition = textFieldState.tokenPositions[token]?.first ?: return@f null diff --git a/gradle.properties b/gradle.properties index 2751022..dc9ad68 100644 --- a/gradle.properties +++ b/gradle.properties @@ -20,4 +20,4 @@ development=true #Publication group=com.zhelenskiy -version=0.0.4 +version=0.0.5