Fixed Join LInes on a block when there is a space in the end of line

This commit is contained in:
Valentin Kipyatkov
2014-12-16 14:00:35 +01:00
parent 478b5070ef
commit bc631d7aee
3 changed files with 6 additions and 3 deletions
@@ -30,7 +30,10 @@ public class JoinBlockIntoSingleStatementHandler : JoinRawLinesHandlerDelegate {
if (file !is JetFile) return -1
if (start == 0) return -1
val brace = file.findElementAt(start - 1)!!
val c = document.getCharsSequence()[start]
val index = if (c == '\n') start - 1 else start
val brace = file.findElementAt(index)!!
if (brace.getNode()!!.getElementType() != JetTokens.LBRACE) return -1
val block = brace.getParent() as? JetBlockExpression ?: return -1
+1 -1
View File
@@ -1,5 +1,5 @@
fun foo() {
<caret>if (a) {
if (a) { <caret>
bar()
}
}
@@ -1,6 +1,6 @@
fun foo(p: Int) {
when (p) {
1 -> {<caret>
1 -> { <caret>
println()
}
}