1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 09:46:02 +02:00

Additional fix and test for bug 322776

This commit is contained in:
Anton Leherbauer 2010-11-18 12:56:32 +00:00
parent 2016e80de8
commit 8ccaca146c
2 changed files with 33 additions and 1 deletions

View file

@ -65,6 +65,7 @@ public class Scribe {
private boolean preserveNewLines;
private boolean checkLineWrapping;
public int lastNumberOfNewLines;
private boolean preserveLineBreakIndentation;
boolean formatBrace;
public int line;
@ -469,6 +470,10 @@ public class Scribe {
if (currentAlignment != null && !formatBrace) {
indentationLevel = currentAlignment.breakIndentationLevel;
}
// Set the flag to indicate that a specific indentation is currently in used
preserveLineBreakIndentation = true;
// Print the computed indentation in the buffer
printIndentationIfNecessary(tempBuffer);
@ -1242,7 +1247,11 @@ public class Scribe {
}
if (lastNumberOfNewLines >= 1) {
// ensure that the scribe is at the beginning of a new line
column = 1;
// only if no specific indentation has been previously set
if (!preserveLineBreakIndentation) {
column = 1;
}
this.preserveLineBreakIndentation = false;
return;
}
addInsertEdit(insertPosition, lineSeparator);
@ -1251,6 +1260,7 @@ public class Scribe {
column= 1;
needSpace= false;
pendingSpace= false;
preserveLineBreakIndentation = false;
}
public void printNextToken(int expectedTokenType) {

View file

@ -1446,6 +1446,28 @@ public class CodeFormatterTest extends BaseUITestCase {
assertFormatterResult();
}
//#define X() { }
//void g() {
// X();
// if (1) {
// x();
// }
// z();
//}
//#define X() { }
//void g() {
// X();
// if (1) {
// x();
// }
// z();
//}
public void testKeepWrappedLines_Bug322776_2() throws Exception {
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_JOIN_WRAPPED_LINES, DefaultCodeFormatterConstants.FALSE);
assertFormatterResult();
}
//void f() {
//double confidence = 0.316030 //
//- 0.016315 * C_Count //