From e6580b0cdb553631e66325de82ec61063fb79e5a Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Tue, 19 Apr 2016 20:46:07 +0300 Subject: [PATCH] Simplified code --- .../idea/completion/handlers/handlerUtils.kt | 21 +++---------------- 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/handlerUtils.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/handlerUtils.kt index 443ffa1cbeb..005b50c275b 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/handlerUtils.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/handlerUtils.kt @@ -124,24 +124,9 @@ fun createKeywordConstructLookupElement( } private fun detectIndent(text: CharSequence, offset: Int): String { - var index = offset - 1 - while (index >= 0) { - val c = text[index] - if (c == '\n' || c == '\r') { - break - } - index-- - } - index++ - - return buildString { - while (index < offset) { - val c = text[index] - if (!c.isWhitespace()) break - append(c) - index++ - } - } + return text.substring(0, offset) + .substringAfterLast('\n') + .takeWhile { it.isWhitespace() } } private fun String.indentLinesAfterFirst(indent: String): String {