diff --git a/gradle.properties b/gradle.properties index 99274e1..77df0ee 100644 --- a/gradle.properties +++ b/gradle.properties @@ -20,4 +20,4 @@ development=true #Publication group=com.zhelenskiy -version=0.0.11 +version=0.0.12 diff --git a/library/src/commonMain/kotlin/kotlinlang/compose/OpeningMultiLineStringQuoteCharHandler.kt b/library/src/commonMain/kotlin/kotlinlang/compose/OpeningMultiLineStringQuoteCharHandler.kt index be9ca20..25d2d5f 100644 --- a/library/src/commonMain/kotlin/kotlinlang/compose/OpeningMultiLineStringQuoteCharHandler.kt +++ b/library/src/commonMain/kotlin/kotlinlang/compose/OpeningMultiLineStringQuoteCharHandler.kt @@ -9,11 +9,12 @@ internal fun openingMultiLineStringQuoteCharHandler( val oldSelection = textFieldState.selection if (!oldSelection.collapsed || oldSelection.end < 2) return@f null if (textFieldState.text[oldSelection.end - 1] != '"' || textFieldState.text[oldSelection.end - 2] != '"') return@f null + val ending = if (oldSelection.end >= 3 && textFieldState.text[oldSelection.end - 3] == '"') "" else "\"\"\"" openingBracketEventHandler( textFieldState = textFieldState, openingChar = '"', openingBracket = "\"", - closingBracket = "\"\"\"", + closingBracket = ending, addNewLinesForSelection = { false }, indent = indent, )(keyboardEvent) diff --git a/library/src/commonMain/kotlin/kotlinlang/tokens/Literals.kt b/library/src/commonMain/kotlin/kotlinlang/tokens/Literals.kt index f475335..36c12f4 100644 --- a/library/src/commonMain/kotlin/kotlinlang/tokens/Literals.kt +++ b/library/src/commonMain/kotlin/kotlinlang/tokens/Literals.kt @@ -243,6 +243,8 @@ internal fun KotlinLexer.readMultiLineLiteral(): List? = buildList } val end = readString("\"\"\"") if (end != null) { + val afterEnd = readWhile { it == '"' } + if (afterEnd.isNotEmpty()) add(Text.RegularLiteral(afterEnd)) mergeLastRegularLiterals() add(Text.MultiLineStringLiteralEnd) break diff --git a/library/src/commonTest/kotlin/LexerTests.kt b/library/src/commonTest/kotlin/LexerTests.kt index 95ba8e3..f61cb44 100644 --- a/library/src/commonTest/kotlin/LexerTests.kt +++ b/library/src/commonTest/kotlin/LexerTests.kt @@ -953,6 +953,26 @@ class LexerTests { ) interpolationTests(quote, MultiLineStringLiteralStart, MultiLineStringLiteralEnd) + + for (quotNumber in 0..20) { + verifyOutput( + input = "\"".repeat(quotNumber + 6), + expectedTokens = listOfNotNull( + MultiLineStringLiteralStart, + RegularLiteral("\"".repeat(quotNumber)).takeIf { quotNumber > 0 }, + MultiLineStringLiteralEnd + ) + ) + verifyOutput( + input = "\"".repeat(quotNumber + 6) +"+3", + expectedTokens = listOfNotNull( + MultiLineStringLiteralStart, + RegularLiteral("\"".repeat(quotNumber)).takeIf { quotNumber > 0 }, + MultiLineStringLiteralEnd, + Add, IntegralNumberLiteral("3") + ) + ) + } } @Test diff --git a/sample/sample.podspec b/sample/sample.podspec index 02f9f33..98cbd93 100644 --- a/sample/sample.podspec +++ b/sample/sample.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = 'sample' - spec.version = '0.0.11' + spec.version = '0.0.12' spec.homepage = 'h' spec.source = { :http=> ''} spec.authors = ''