Skip to content

Commit 4398031

Browse files
bergmeisterrjmholt
andauthored
Update Rules/UseConsistentIndentation.cs
Co-Authored-By: Robert Holt <[email protected]>
1 parent 295c534 commit 4398031

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

Rules/UseConsistentIndentation.cs

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -254,19 +254,33 @@ public override IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string file
254254
return diagnosticRecords;
255255
}
256256

257-
private static bool PipelineIsFollowedByNewlineOrLineContinuation(Token[] tokens, int tokenIndex)
257+
private static bool PipelineIsFollowedByNewlineOrLineContinuation(Token[] tokens, int startIndex)
258258
{
259-
if (tokenIndex == tokens.Length - 1)
259+
if (startIndex >= tokens.Length - 1)
260260
{
261261
return false;
262262
}
263-
var nextToken = tokens[tokenIndex + 1];
264-
if (nextToken.Kind == TokenKind.Comment && tokenIndex < tokens.Length - 2)
263+
264+
Token nextToken = null;
265+
for (int i = startIndex + 1; i < tokens.Length; i++)
265266
{
266-
nextToken = tokens[tokenIndex + 2];
267+
nextToken = tokens[i];
268+
269+
switch (nextToken.Kind)
270+
{
271+
case TokenKind.Comment:
272+
continue;
273+
274+
case TokenKind.NewLine:
275+
case TokenKind.LineContinuation:
276+
return true;
277+
278+
default:
279+
return false;
267280
}
268-
return nextToken.Kind == TokenKind.NewLine ||
269-
nextToken.Kind == TokenKind.LineContinuation;
281+
282+
// We've run out of tokens but haven't seen a newline
283+
return false;
270284
}
271285

272286
private static bool LineHasPipelineBeforeToken(Token[] tokens, int tokenIndex, Token token)

0 commit comments

Comments
 (0)