SortContentAction: fix warping in the middle of initializer: IDEA-185786

This commit is contained in:
Roman Ivanov
2018-01-30 13:58:05 +07:00
parent 2ad398daa9
commit 798fea215a
4 changed files with 38 additions and 2 deletions
@@ -375,7 +375,7 @@ public class SortContentAction extends PsiElementBaseIntentionAction {
}
for (int rowPosition = 0; rowPosition < entryCountOnRow; rowPosition++) {
currentEntryIndex++;
boolean isLastInRow = rowPosition + 1 == entryCountOnRow && rowPosition + 1 != lines;
boolean isLastInRow = rowPosition + 1 == entryCountOnRow && rowIndex + 1 != lines;
entries.get(entryIndex).generate(sb, isLastInRow, currentEntryIndex == entryCount);
entryIndex++;
}
@@ -2,7 +2,8 @@
<body>
Intention to sort content of array or vararg.
<!-- tooltip end -->
<p>This intention can sort literals (int and string) and enum constants.</p>>
<p>This intention can sort literals (int and string) and enum constants.</p>
<p>Inspection tries to preserve count of expression on line, but in case of comments it is not always possible.</p>
<small>New in 2018.1</small>
</body>
</html>
@@ -0,0 +1,18 @@
// "Sort content" "true"
import java.util.*;
public class Main {
private void test() {
String[] LAST_NAMES = new String[]{
//A
"Allen", "Anderson", "Brown", "Clark", "Davis", "Garcia", "Hall",
"Harris", "Jackson", "Johnson", "Jones", "Lee", "Lewis", "Martin",
"Martinez", "Miller", "Moore", "Robinson", "Rodriguez", "Smith", "Taylor",
"Thomas", "Thompson", "Walker", "White", //B
"Williams", "Wilson", "Young"//Z
};
}
}
@@ -0,0 +1,17 @@
// "Sort content" "true"
import java.util.*;
public class Main {
private void test() {
String[] LAST_NAMES = new String[]{
//A
"Smith", "Johnson", "Williams", "Jones", "Brown", "Davis", "Miller",
"Wilson", "Moore", "Taylor", "Anderson", "Thomas", "Jackson", "White",
//B<caret>
"Harris", "Martin", "Thompson", "Garcia", "Martinez", "Robinson", "Clark",
"Rodriguez", "Lewis", "Lee", "Walker", "Hall", "Allen", "Young"
//Z
};
}
}