Fix scripting formatter to avoid extra indent in invisible block node.
This commit is contained in:
committed by
Andrey Breslav
parent
480dd6767c
commit
64b4c2d49b
@@ -267,7 +267,7 @@ public class JetBlock extends AbstractBlock {
|
||||
.forType(PROPERTY_ACCESSOR)
|
||||
.set(Indent.getNormalIndent()),
|
||||
|
||||
ASTIndentStrategy.forNode("For a single statement if 'for'")
|
||||
ASTIndentStrategy.forNode("For a single statement in 'for'")
|
||||
.in(BODY)
|
||||
.notForType(BLOCK)
|
||||
.set(Indent.getNormalIndent()),
|
||||
@@ -302,6 +302,13 @@ public class JetBlock extends AbstractBlock {
|
||||
ASTNode childParent = child.getTreeParent();
|
||||
IElementType childType = child.getElementType();
|
||||
|
||||
// SCRIPT: Avoid indenting script top BLOCK contents
|
||||
if (childParent != null && childParent.getTreeParent() != null) {
|
||||
if (childParent.getElementType() == BLOCK && childParent.getTreeParent().getElementType() == SCRIPT) {
|
||||
return Indent.getNoneIndent();
|
||||
}
|
||||
}
|
||||
|
||||
for (ASTIndentStrategy strategy : INDENT_RULES) {
|
||||
Indent indent = strategy.getIndent(child);
|
||||
if (indent != null) {
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import a.b.c
|
||||
|
||||
val x = 0
|
||||
fun fn() {
|
||||
println(x)
|
||||
}
|
||||
|
||||
var y = fn()
|
||||
y = y + 1
|
||||
@@ -0,0 +1,8 @@
|
||||
import a.b.c
|
||||
val x = 0
|
||||
fun fn() {
|
||||
println(x)
|
||||
}
|
||||
|
||||
var y = fn()
|
||||
y = y+1
|
||||
Reference in New Issue
Block a user