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;
|
return;
|
||||||
immutable bool arrayInitializerStart = p == tok!"["
|
immutable bool arrayInitializerStart = p == tok!"["
|
||||||
&& astInformation.arrayStartLocations.canFindIndex(tokens[index - 1].index);
|
&& 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
|
// Use the close bracket as the indent token to distinguish
|
||||||
// the array initialiazer from an array index in the newline
|
// the array initialiazer from an array index in the newline
|
||||||
|
@ -644,6 +644,26 @@ private:
|
||||||
writeToken();
|
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()
|
void formatAt()
|
||||||
{
|
{
|
||||||
immutable size_t atIndex = tokens[index].index;
|
immutable size_t atIndex = tokens[index].index;
|
||||||
|
@ -1258,17 +1278,7 @@ private:
|
||||||
formatColon();
|
formatColon();
|
||||||
break;
|
break;
|
||||||
case tok!"]":
|
case tok!"]":
|
||||||
indents.popWrapIndents();
|
formatRightBracket();
|
||||||
if (indents.topIs(tok!"]"))
|
|
||||||
{
|
|
||||||
if (!indents.topDetails.mini)
|
|
||||||
newline();
|
|
||||||
else
|
|
||||||
indents.pop();
|
|
||||||
}
|
|
||||||
writeToken();
|
|
||||||
if (currentIs(tok!"identifier"))
|
|
||||||
write(" ");
|
|
||||||
break;
|
break;
|
||||||
case tok!";":
|
case tok!";":
|
||||||
formatSemicolon();
|
formatSemicolon();
|
||||||
|
|
Loading…
Reference in New Issue