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