Skip to content

Commit caeddf5

Browse files
committed
Fix formatting in case when there are block comments right before declarations
1 parent acbd99b commit caeddf5

File tree

4 files changed

+34
-2
lines changed

4 files changed

+34
-2
lines changed

kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/formatter/KotlinFormatActionTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,9 @@ public void formatSelection() {
113113
public void respectCaretAfterFormatting() {
114114
doAutoTest();
115115
}
116+
117+
@Test
118+
public void blockCommentBeforeDeclaration() {
119+
doAutoTest();
120+
}
116121
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Cls{
2+
/*
3+
*/
4+
fun test() {}
5+
6+
/*
7+
*/
8+
val vls = 1
9+
10+
/*
11+
*/
12+
companion object {}
13+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Cls {
2+
/*
3+
*/
4+
fun test() {
5+
}
6+
7+
/*
8+
*/
9+
val vls = 1
10+
11+
/*
12+
*/
13+
companion object {}
14+
}

kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/formatter/EclipseDocumentFormattingModel.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ public TextRange replaceWhiteSpace(TextRange textRange, @Nullable ASTNode nodeAf
8080
@Override
8181
public TextRange shiftIndentInsideRange(ASTNode node, TextRange range, int indent) {
8282
try {
83-
int newLength = shiftIndentInside(range, indent);
84-
return new TextRange(range.getStartOffset(), range.getStartOffset() + newLength);
83+
shiftIndentInside(range, indent);
84+
return range;
8585
} catch (BadLocationException e) {
8686
KotlinLogger.logAndThrow(e);
8787
}

0 commit comments

Comments
 (0)