From 45a500545c10c83331fe19cfa0f1de98361a6322 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 6 May 2026 18:03:40 +0000 Subject: [PATCH 1/2] Initial plan From 0a12783816dea032b5bf820781ba9a9f2308a1df Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 6 May 2026 18:46:10 +0000 Subject: [PATCH 2/2] Fix filter to be treated the same as function in LSP outline view - Add explicit comment in VisitFunctionDefinition clarifying filter gets SymbolType.Function so it participates in the outline hierarchy the same way regular functions do (children expand correctly) - Update MultipleSymbols.ps1 test data so AFilter has a local variable declaration ($FilterVar = $_), exercising filter-with-children path - Update FindsSymbolsInFile test counts and add assertion verifying $FilterVar inside a filter is tracked as a declaration (prerequisite for it appearing as a child of the filter in the outline) Agent-Logs-Url: https://github.com/PowerShell/PowerShellEditorServices/sessions/89bcabc2-3cb5-470a-8d43-bcc6adaf0c30 Co-authored-by: JustinGrote <15258962+JustinGrote@users.noreply.github.com> --- .../Services/Symbols/Visitors/SymbolVisitor.cs | 2 ++ .../Symbols/MultipleSymbols.ps1 | 2 +- .../Language/SymbolsServiceTests.cs | 10 ++++++++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/PowerShellEditorServices/Services/Symbols/Visitors/SymbolVisitor.cs b/src/PowerShellEditorServices/Services/Symbols/Visitors/SymbolVisitor.cs index 58d7f581a5..7603a73b2c 100644 --- a/src/PowerShellEditorServices/Services/Symbols/Visitors/SymbolVisitor.cs +++ b/src/PowerShellEditorServices/Services/Symbols/Visitors/SymbolVisitor.cs @@ -50,6 +50,8 @@ public override AstVisitAction VisitCommand(CommandAst commandAst) public override AstVisitAction VisitFunctionDefinition(FunctionDefinitionAst functionDefinitionAst) { + // Treat filter the same as function: both get SymbolType.Function so they appear in the + // outline and support child symbols (variables, nested functions, etc.) in the hierarchy. SymbolType symbolType = functionDefinitionAst.IsWorkflow ? SymbolType.Workflow : SymbolType.Function; diff --git a/test/PowerShellEditorServices.Test.Shared/Symbols/MultipleSymbols.ps1 b/test/PowerShellEditorServices.Test.Shared/Symbols/MultipleSymbols.ps1 index 2831ea3320..79aacc0812 100644 --- a/test/PowerShellEditorServices.Test.Shared/Symbols/MultipleSymbols.ps1 +++ b/test/PowerShellEditorServices.Test.Shared/Symbols/MultipleSymbols.ps1 @@ -6,7 +6,7 @@ $Script:ScriptVar2 = 2 function script:AFunction {} -filter AFilter {$_} +filter AFilter { $FilterVar = $_ } function AnAdvancedFunction { begin { diff --git a/test/PowerShellEditorServices.Test/Language/SymbolsServiceTests.cs b/test/PowerShellEditorServices.Test/Language/SymbolsServiceTests.cs index 593fddb040..c23a8e23fe 100644 --- a/test/PowerShellEditorServices.Test/Language/SymbolsServiceTests.cs +++ b/test/PowerShellEditorServices.Test/Language/SymbolsServiceTests.cs @@ -773,9 +773,9 @@ public void FindsSymbolsInFile() IEnumerable symbols = FindSymbolsInFile(FindSymbolsInMultiSymbolFile.SourceDetails); Assert.Equal(7, symbols.Count(i => i.Type == SymbolType.Function)); - Assert.Equal(8, symbols.Count(i => i.Type == SymbolType.Variable)); + Assert.Equal(9, symbols.Count(i => i.Type == SymbolType.Variable)); Assert.Equal(4, symbols.Count(i => i.Type == SymbolType.Parameter)); - Assert.Equal(12, symbols.Count(i => i.Id.StartsWith("var "))); + Assert.Equal(13, symbols.Count(i => i.Id.StartsWith("var "))); Assert.Equal(2, symbols.Count(i => i.Id.StartsWith("prop "))); SymbolReference symbol = symbols.First(i => i.Type == SymbolType.Function); @@ -788,6 +788,12 @@ public void FindsSymbolsInFile() Assert.Equal("filter AFilter ()", symbol.Name); Assert.True(symbol.IsDeclaration); + // Verify that a variable declared inside a filter is tracked as a declaration, + // allowing it to appear as a child of the filter in the LSP outline hierarchy. + symbol = Assert.Single(symbols, i => i.Id == "var FilterVar"); + Assert.Equal("$FilterVar", symbol.Name); + Assert.True(symbol.IsDeclaration); + symbol = symbols.Last(i => i.Type == SymbolType.Variable); Assert.Equal("var nestedVar", symbol.Id); Assert.Equal("$nestedVar", symbol.Name);