Skip to content

Commit

Permalink
(PowerShellGH-811) Add support for unopinionated variable name in folder
Browse files Browse the repository at this point in the history
Previously the code folder was not aware of unopinionated variable name
assignments.  This commit adds detection and an appropriate test.
  • Loading branch information
glennsarti committed Dec 12, 2018
1 parent 02273eb commit 8ba0ed4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/PowerShellEditorServices/Language/TokenOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ internal static FoldingReference[] FoldableRegions(
MatchTokenElement(tokens, TokenKind.HereStringLiteral, RegionKindNone)
);

// Find unopinionated variable names ${ \n \n }
foldableRegions.AddRange(
MatchTokenElement(tokens, TokenKind.Variable, RegionKindNone)
);

// Find contiguous here strings @" -> "@
foldableRegions.AddRange(
MatchTokenElement(tokens, TokenKind.HereStringExpandable, RegionKindNone)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,13 @@ double quoted herestrings should also fold
# Comment Block 2
# Comment Block 2
$something = $true
#endregion Comment Block 3";
#endregion Comment Block 3
# What about anonymous variable assignment
${this
is
valid} = 5
";
private FoldingReference[] expectedAllInOneScriptFolds = {
CreateFoldingReference(0, 0, 3, 10, "region"),
CreateFoldingReference(1, 0, 2, 2, "comment"),
Expand All @@ -127,7 +133,8 @@ double quoted herestrings should also fold
CreateFoldingReference(56, 7, 58, 3, null),
CreateFoldingReference(64, 0, 65, 0, "comment"),
CreateFoldingReference(67, 0, 71, 26, "region"),
CreateFoldingReference(68, 0, 69, 0, "comment")
CreateFoldingReference(68, 0, 69, 0, "comment"),
CreateFoldingReference(75, 0, 76, 6, null),
};

/// <summary>
Expand Down Expand Up @@ -244,6 +251,5 @@ public void LaguageServiceFindsFoldablRegionsWithSameEndToken() {

AssertFoldingReferenceArrays(expectedFolds, result);
}

}
}

0 comments on commit 8ba0ed4

Please sign in to comment.