Fix: indentation for wrapping in struct initializer
This commit is contained in:
parent
81c607a115
commit
05db8ae8fa
|
@ -1515,7 +1515,7 @@ private:
|
|||
void newline()
|
||||
{
|
||||
import std.range : assumeSorted;
|
||||
import std.algorithm : max;
|
||||
import std.algorithm : max, canFind;
|
||||
import dfmt.editorconfig : OptionalBoolean;
|
||||
|
||||
if (currentIs(tok!"comment") && index > 0 && current.line == tokenEndLine(tokens[index - 1]))
|
||||
|
@ -1558,6 +1558,12 @@ private:
|
|||
immutable l = indents.indentToMostRecent(tok!"switch");
|
||||
if (l != -1 && config.dfmt_align_switch_statements == OptionalBoolean.t)
|
||||
indentLevel = l;
|
||||
else if (astInformation.structInfoSortedByEndLocation
|
||||
.canFind!(st => st.startLocation < current.index && current.index < st.endLocation)) {
|
||||
immutable l2 = indents.indentToMostRecent(tok!"{");
|
||||
assert(l2 != -1);
|
||||
indentLevel = l2 + 1;
|
||||
}
|
||||
else if (config.dfmt_compact_labeled_statements == OptionalBoolean.f
|
||||
|| !isBlockHeader(2) || peek2Is(tok!"if"))
|
||||
{
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
void foo()
|
||||
void main()
|
||||
{
|
||||
S s1 = {a: 3};
|
||||
S s2 = {a: 3, b: "test string"};
|
||||
S s3 = {a: 3, b: "test string", c: {x: 3.14, y: 3 + 4}};
|
||||
S s = {
|
||||
someStructMember1: 2, someStructMember2: 42, someStructMember3: null, // foobar
|
||||
someOtherMember1: objA, someOtherMember2: objB, someOtherMember3: 0,
|
||||
somethingMore: null, someFlagInThisStruct: -1
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
void foo()
|
||||
{
|
||||
S s1 = { a: 3 };
|
||||
S s2 = { a: 3, b:"test string" };
|
||||
S s3 = { a: 3, b:"test string", c: {x: 3.14, y: 3 + 4} };
|
||||
void main() {
|
||||
S s = {
|
||||
someStructMember1: 2,
|
||||
someStructMember2: 42,
|
||||
someStructMember3: null, // foobar
|
||||
someOtherMember1: objA,
|
||||
someOtherMember2: objB,
|
||||
someOtherMember3: 0,
|
||||
somethingMore: null,
|
||||
someFlagInThisStruct: -1
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
void foo() {
|
||||
S s1 = {a: 3};
|
||||
S s2 = {a: 3, b: "test string"};
|
||||
S s3 = {a: 3, b: "test string", c: {x: 3.14, y: 3 + 4}};
|
||||
void main() {
|
||||
S s = {
|
||||
someStructMember1: 2, someStructMember2: 42, someStructMember3: null, // foobar
|
||||
someOtherMember1: objA, someOtherMember2: objB, someOtherMember3: 0,
|
||||
somethingMore: null, someFlagInThisStruct: -1
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue