Fix isMultilineAt for array + refactor right bracket
Refactor formatRightBracket into own function
This commit is contained in:
parent
48b2b84c33
commit
1da1ca6545
|
@ -571,7 +571,7 @@ private:
|
|||
return;
|
||||
immutable bool arrayInitializerStart = p == tok!"["
|
||||
&& astInformation.arrayStartLocations.canFindIndex(tokens[index - 1].index);
|
||||
if (arrayInitializerStart && isMultilineAt(index))
|
||||
if (arrayInitializerStart && isMultilineAt(index - 1))
|
||||
{
|
||||
// Use the close bracket as the indent token to distinguish
|
||||
// the array initialiazer from an array index in the newline
|
||||
|
@ -644,6 +644,26 @@ private:
|
|||
writeToken();
|
||||
}
|
||||
|
||||
void formatRightBracket()
|
||||
in
|
||||
{
|
||||
assert(currentIs(tok!"]"));
|
||||
}
|
||||
body
|
||||
{
|
||||
indents.popWrapIndents();
|
||||
if (indents.topIs(tok!"]"))
|
||||
{
|
||||
if (!indents.topDetails.mini)
|
||||
newline();
|
||||
else
|
||||
indents.pop();
|
||||
}
|
||||
writeToken();
|
||||
if (currentIs(tok!"identifier"))
|
||||
write(" ");
|
||||
}
|
||||
|
||||
void formatAt()
|
||||
{
|
||||
immutable size_t atIndex = tokens[index].index;
|
||||
|
@ -1258,17 +1278,7 @@ private:
|
|||
formatColon();
|
||||
break;
|
||||
case tok!"]":
|
||||
indents.popWrapIndents();
|
||||
if (indents.topIs(tok!"]"))
|
||||
{
|
||||
if (!indents.topDetails.mini)
|
||||
newline();
|
||||
else
|
||||
indents.pop();
|
||||
}
|
||||
writeToken();
|
||||
if (currentIs(tok!"identifier"))
|
||||
write(" ");
|
||||
formatRightBracket();
|
||||
break;
|
||||
case tok!";":
|
||||
formatSemicolon();
|
||||
|
|
Loading…
Reference in New Issue