View | Details | Raw Unified | Return to bug 208541 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java (+11 lines)
Lines 9627-9630 Link Here
9627
		};
9627
		};
9628
		runTest(codeFormatter, "test688", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$
9628
		runTest(codeFormatter, "test688", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$
9629
	}
9629
	}
9630
	
9631
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=208541
9632
	public void test689() {
9633
		final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings();
9634
		DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options);
9635
		DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences);
9636
		IRegion[] regions = new IRegion[] {
9637
				new Region(33, 19)
9638
		};
9639
		runTest(codeFormatter, "test689", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$
9640
	}
9630
}
9641
}
(-)workspace/Formatter/test689/A_in.java (+5 lines)
Added Link Here
1
package pkg1;
2
public class A {
3
        int i = 1;     
4
5
}
(-)workspace/Formatter/test689/A_out.java (+5 lines)
Added Link Here
1
package pkg1;
2
public class A {
3
	int i = 1;
4
5
}
(-)formatter/org/eclipse/jdt/internal/formatter/Scribe.java (-6 / +6 lines)
Lines 728-739 Link Here
728
		if (span > this.pageWidth) {
728
		if (span > this.pageWidth) {
729
			return false;
729
			return false;
730
		}
730
		}
731
		// more than one line selected
731
		if (this.line > 1 && this.lineEnds != null && this.lineEnds.length > 0) { // CU has more than one line
732
		if (span > this.getLineEnd(this.scanner.getLineNumber(offset) + 1)) {
732
			if (span >= this.getLineEnd(Util.getLineNumber(offset, this.lineEnds, 0, this.line))) {
733
			return false;
733
				return false; // more than one line selected, no need to adapt region
734
		// region is on a single line and CU has more than one line
734
			} else {
735
		} else if (this.lineEnds != null && this.lineEnds.length > 1) {
735
				return true; // single line selected - adapt region
736
			return true;
736
			}
737
		}
737
		}
738
		return false;
738
		return false;
739
	}
739
	}

Return to bug 208541