if comma is followed by whitespace, wrap after whitespace rather than before it

This commit is contained in:
Dmitry Jemerov
2010-09-23 22:08:46 +04:00
parent 2bd318b68c
commit 80d934c2d5
2 changed files with 9 additions and 3 deletions
@@ -78,8 +78,14 @@ public class GenericLineWrapPositionStrategy implements LineWrapPositionStrategy
Rule rule = myRules.get(c);
if (rule != null) {
if (rule.condition == WrapCondition.BOTH || rule.condition == WrapCondition.AFTER) {
if (i < maxPreferredOffsetToUse) {
offset2Weight.put(i + 1, rule.weight);
int target = i+1;
if (rule.symbol != ' ') {
while(i < maxPreferredOffsetToUse && text.charAt(target) == ' ') {
target++;
}
}
if (target <= maxPreferredOffsetToUse) {
offset2Weight.put(target, rule.weight);
}
}
@@ -53,7 +53,7 @@ public class DefaultLineWrapPositionStrategyTest {
@Test
public void preferWrapOnComma() {
String document =
"int variable = testMethod(var1 + var2,<WRAP> var3 + va<EDGE>r4);";
"int variable = testMethod(var1 + var2, <WRAP>var3 + va<EDGE>r4);";
doTest(document);
}