diff --git a/idea/line-indent-provider/src/org/jetbrains/kotlin/idea/formatter/lineIndent/KotlinLikeLangLineIndentProvider.kt b/idea/line-indent-provider/src/org/jetbrains/kotlin/idea/formatter/lineIndent/KotlinLikeLangLineIndentProvider.kt index a858836ec2c..7f49617f96f 100644 --- a/idea/line-indent-provider/src/org/jetbrains/kotlin/idea/formatter/lineIndent/KotlinLikeLangLineIndentProvider.kt +++ b/idea/line-indent-provider/src/org/jetbrains/kotlin/idea/formatter/lineIndent/KotlinLikeLangLineIndentProvider.kt @@ -25,10 +25,34 @@ abstract class KotlinLikeLangLineIndentProvider : JavaLikeLangLineIndentProvider override fun isSuitableForLanguage(language: Language): Boolean = language.isKindOf(KotlinLanguage.INSTANCE) + private fun debugInfo(currentPosition: SemanticEditorPosition): String { + val after = currentPosition.after() + val before = currentPosition.before() + val chars = currentPosition.chars + fun print(position: SemanticEditorPosition, next: SemanticEditorPosition? = null) = "${position.currElement} =>\n'${ + if (position.isAtEnd) + "end" + else + chars.subSequence(position.startOffset, next?.takeIf { !it.isAtEnd }?.startOffset ?: chars.length) + }'" + + return "==\nbefore ${ + print(before, currentPosition) + }\ncurr ${ + print(currentPosition, after) + }\nafter ${ + print(after) + }\n==" + } + override fun getIndent(project: Project, editor: Editor, language: Language?, offset: Int): IndentCalculator? { val factory = IndentCalculatorFactory(project, editor) val currentPosition = getPosition(editor, offset) + // ~~~ TESTING ~~~ +// println(debugInfo(currentPosition)) + // ~~~ TESTING ~~~ + currentPosition.beforeOptionalMix(Whitespace, LineComment) .takeIf { it.isAt(TemplateEntryOpen) } ?.let { templateEntryPosition ->