Add documentation/comments & undo minor name change
This commit is contained in:
parent
fcad21ba61
commit
48b2b84c33
|
@ -579,6 +579,9 @@ private:
|
||||||
IndentStack.Details detail;
|
IndentStack.Details detail;
|
||||||
detail.wrap = false;
|
detail.wrap = false;
|
||||||
detail.temp = true;
|
detail.temp = true;
|
||||||
|
// wrap and temp are set manually to the values it would actually
|
||||||
|
// receive here because we want to set isAA for the ] token to know if
|
||||||
|
// we should definitely always new-line after every comma for a big AA
|
||||||
detail.isAA = astInformation.assocArrayStartLocations.canFindIndex(tokens[index - 1].index);
|
detail.isAA = astInformation.assocArrayStartLocations.canFindIndex(tokens[index - 1].index);
|
||||||
pushWrapIndent(tok!"]", detail);
|
pushWrapIndent(tok!"]", detail);
|
||||||
|
|
||||||
|
@ -1256,7 +1259,7 @@ private:
|
||||||
break;
|
break;
|
||||||
case tok!"]":
|
case tok!"]":
|
||||||
indents.popWrapIndents();
|
indents.popWrapIndents();
|
||||||
if (indents.topIsTemp(tok!"]"))
|
if (indents.topIs(tok!"]"))
|
||||||
{
|
{
|
||||||
if (!indents.topDetails.mini)
|
if (!indents.topDetails.mini)
|
||||||
newline();
|
newline();
|
||||||
|
@ -1389,7 +1392,7 @@ private:
|
||||||
writeToken();
|
writeToken();
|
||||||
newline();
|
newline();
|
||||||
}
|
}
|
||||||
else if (indents.topIsTemp(tok!"]") && indents.topDetails.isAA && !indents.topDetails.mini)
|
else if (indents.topIs(tok!"]") && indents.topDetails.isAA && !indents.topDetails.mini)
|
||||||
{
|
{
|
||||||
writeToken();
|
writeToken();
|
||||||
newline();
|
newline();
|
||||||
|
@ -1428,7 +1431,7 @@ private:
|
||||||
: tokens[i .. $].countUntil!(t => t.index == r.front) + i;
|
: tokens[i .. $].countUntil!(t => t.index == r.front) + i;
|
||||||
immutable size_t j = min(expressionEndIndex(i), ufcsBreakLocation);
|
immutable size_t j = min(expressionEndIndex(i), ufcsBreakLocation);
|
||||||
// Use magical negative value for array literals and wrap indents
|
// Use magical negative value for array literals and wrap indents
|
||||||
immutable inLvl = (indents.topIsWrap() || indents.topIsTemp(tok!"]")) ? -indentLevel
|
immutable inLvl = (indents.topIsWrap() || indents.topIs(tok!"]")) ? -indentLevel
|
||||||
: indentLevel;
|
: indentLevel;
|
||||||
linebreakHints = chooseLineBreakTokens(i, tokens[i .. j], depths[i .. j],
|
linebreakHints = chooseLineBreakTokens(i, tokens[i .. j], depths[i .. j],
|
||||||
config, currentLineLength, inLvl);
|
config, currentLineLength, inLvl);
|
||||||
|
@ -1554,7 +1557,7 @@ private:
|
||||||
else if (currentIs(tok!"]"))
|
else if (currentIs(tok!"]"))
|
||||||
{
|
{
|
||||||
indents.popWrapIndents();
|
indents.popWrapIndents();
|
||||||
if (indents.topIsTemp(tok!"]"))
|
if (indents.topIs(tok!"]"))
|
||||||
{
|
{
|
||||||
indents.pop();
|
indents.pop();
|
||||||
indentLevel = indents.indentLevel;
|
indentLevel = indents.indentLevel;
|
||||||
|
@ -1734,6 +1737,8 @@ const pure @safe @nogc:
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns: true when the expression starting at index goes over the line length limit.
|
||||||
|
/// Uses matching `{}` or `[]` or otherwise takes everything up until a semicolon or opening brace using expressionEndIndex.
|
||||||
bool isMultilineAt(size_t i)
|
bool isMultilineAt(size_t i)
|
||||||
{
|
{
|
||||||
import std.algorithm : map, sum, canFind;
|
import std.algorithm : map, sum, canFind;
|
||||||
|
|
|
@ -184,6 +184,8 @@ int breakCost(IdType p, IdType c) pure nothrow @safe @nogc
|
||||||
case tok!"+=":
|
case tok!"+=":
|
||||||
return 200;
|
return 200;
|
||||||
case tok!":":
|
case tok!":":
|
||||||
|
// colon could be after a label or an import, where it should normally wrap like before
|
||||||
|
// for everything else (associative arrays) try not breaking around colons
|
||||||
return p == tok!"identifier" ? 0 : 300;
|
return p == tok!"identifier" ? 0 : 300;
|
||||||
case tok!".":
|
case tok!".":
|
||||||
return p == tok!")" ? 0 : 300;
|
return p == tok!")" ? 0 : 300;
|
||||||
|
|
Loading…
Reference in New Issue