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 preserveNewLines;
|
||||||
private boolean checkLineWrapping;
|
private boolean checkLineWrapping;
|
||||||
public int lastNumberOfNewLines;
|
public int lastNumberOfNewLines;
|
||||||
|
private boolean preserveLineBreakIndentation;
|
||||||
boolean formatBrace;
|
boolean formatBrace;
|
||||||
public int line;
|
public int line;
|
||||||
|
|
||||||
|
@ -469,6 +470,10 @@ public class Scribe {
|
||||||
if (currentAlignment != null && !formatBrace) {
|
if (currentAlignment != null && !formatBrace) {
|
||||||
indentationLevel = currentAlignment.breakIndentationLevel;
|
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
|
// Print the computed indentation in the buffer
|
||||||
printIndentationIfNecessary(tempBuffer);
|
printIndentationIfNecessary(tempBuffer);
|
||||||
|
|
||||||
|
@ -1242,7 +1247,11 @@ public class Scribe {
|
||||||
}
|
}
|
||||||
if (lastNumberOfNewLines >= 1) {
|
if (lastNumberOfNewLines >= 1) {
|
||||||
// ensure that the scribe is at the beginning of a new line
|
// 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;
|
return;
|
||||||
}
|
}
|
||||||
addInsertEdit(insertPosition, lineSeparator);
|
addInsertEdit(insertPosition, lineSeparator);
|
||||||
|
@ -1251,6 +1260,7 @@ public class Scribe {
|
||||||
column= 1;
|
column= 1;
|
||||||
needSpace= false;
|
needSpace= false;
|
||||||
pendingSpace= false;
|
pendingSpace= false;
|
||||||
|
preserveLineBreakIndentation = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printNextToken(int expectedTokenType) {
|
public void printNextToken(int expectedTokenType) {
|
||||||
|
|
|
@ -1446,6 +1446,28 @@ public class CodeFormatterTest extends BaseUITestCase {
|
||||||
assertFormatterResult();
|
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() {
|
//void f() {
|
||||||
//double confidence = 0.316030 //
|
//double confidence = 0.316030 //
|
||||||
//- 0.016315 * C_Count //
|
//- 0.016315 * C_Count //
|
||||||
|
|
Loading…
Add table
Reference in a new issue