mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +02:00
Additional fix and test for bug 322776
This commit is contained in:
parent
2016e80de8
commit
8ccaca146c
2 changed files with 33 additions and 1 deletions
|
@ -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) {
|
||||
|
|
|
@ -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 //
|
||||
|
|
Loading…
Add table
Reference in a new issue