Skip to content

Commit 5c13ef2

Browse files
JustinGroteCopilot
andauthored
Apply suggestions from Copliot
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 0a12783 commit 5c13ef2

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

src/PowerShellEditorServices/Services/Symbols/Visitors/SymbolVisitor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ public override AstVisitAction VisitCommand(CommandAst commandAst)
5050

5151
public override AstVisitAction VisitFunctionDefinition(FunctionDefinitionAst functionDefinitionAst)
5252
{
53-
// Treat filter the same as function: both get SymbolType.Function so they appear in the
54-
// outline and support child symbols (variables, nested functions, etc.) in the hierarchy.
53+
// Treat filter the same as function: both get SymbolType.Function so they use the same
54+
// function-like symbol kind. Document-symbol inclusion and child hierarchy are determined elsewhere.
5555
SymbolType symbolType = functionDefinitionAst.IsWorkflow
5656
? SymbolType.Workflow
5757
: SymbolType.Function;

test/PowerShellEditorServices.Test/Language/SymbolsServiceTests.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -789,11 +789,19 @@ public void FindsSymbolsInFile()
789789
Assert.True(symbol.IsDeclaration);
790790

791791
// Verify that a variable declared inside a filter is tracked as a declaration,
792-
// allowing it to appear as a child of the filter in the LSP outline hierarchy.
792+
// and that it is returned as a child of the filter in the LSP outline hierarchy.
793793
symbol = Assert.Single(symbols, i => i.Id == "var FilterVar");
794794
Assert.Equal("$FilterVar", symbol.Name);
795795
Assert.True(symbol.IsDeclaration);
796796

797+
DocumentSymbol filterDocumentSymbol = Assert.Single(
798+
GetDocumentSymbols(FindSymbolsInMultiSymbolFile.SourceDetails),
799+
i => i.Name == "AFilter");
800+
DocumentSymbol filterVariableDocumentSymbol = Assert.Single(
801+
filterDocumentSymbol.Children,
802+
i => i.Name == "$FilterVar");
803+
Assert.Equal(SymbolKind.Variable, filterVariableDocumentSymbol.Kind);
804+
797805
symbol = symbols.Last(i => i.Type == SymbolType.Variable);
798806
Assert.Equal("var nestedVar", symbol.Id);
799807
Assert.Equal("$nestedVar", symbol.Name);

0 commit comments

Comments
 (0)