diff --git a/src/PowerShellEditorServices/Language/TokenOperations.cs b/src/PowerShellEditorServices/Language/TokenOperations.cs index 6ed140c9e..42365e8ee 100644 --- a/src/PowerShellEditorServices/Language/TokenOperations.cs +++ b/src/PowerShellEditorServices/Language/TokenOperations.cs @@ -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) diff --git a/test/PowerShellEditorServices.Test/Language/TokenOperationsTests.cs b/test/PowerShellEditorServices.Test/Language/TokenOperationsTests.cs index ce16015a6..415e9af4a 100644 --- a/test/PowerShellEditorServices.Test/Language/TokenOperationsTests.cs +++ b/test/PowerShellEditorServices.Test/Language/TokenOperationsTests.cs @@ -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"), @@ -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), }; /// @@ -244,6 +251,5 @@ public void LaguageServiceFindsFoldablRegionsWithSameEndToken() { AssertFoldingReferenceArrays(expectedFolds, result); } - } }