File tree Expand file tree Collapse file tree 3 files changed +12
-2
lines changed
src/PowerShellEditorServices/Services/Symbols
PowerShellEditorServices.Test.Shared/References
PowerShellEditorServices.Test/Language Expand file tree Collapse file tree 3 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -94,6 +94,15 @@ private AstVisitAction AddReference(SymbolReference symbol)
9494 _ => new ConcurrentBag < SymbolReference > { symbol } ,
9595 ( _ , existing ) =>
9696 {
97+ // Keep only the first variable encountered as a declaration marked as such. This
98+ // keeps the first assignment without also counting every reassignment as a
99+ // declaration (cleaning up e.g. Code's outline view).
100+ if ( symbol . Type is SymbolType . Variable && symbol . IsDeclaration
101+ && existing . Any ( i => i . IsDeclaration ) )
102+ {
103+ symbol = symbol with { IsDeclaration = false } ;
104+ }
105+
97106 existing . Add ( symbol ) ;
98107 return existing ;
99108 } ) ;
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ function My-Function ($myInput)
55
66$things = 4
77
8- $things
8+ $things = 3
99
1010My- Function $things
1111
Original file line number Diff line number Diff line change @@ -263,7 +263,8 @@ public async Task FindsFunctionDefinitionInWorkspace()
263263 [ Fact ]
264264 public async Task FindsVariableDefinition ( )
265265 {
266- SymbolReference symbol = await GetDefinition ( FindsVariableDefinitionData . SourceDetails ) . ConfigureAwait ( true ) ;
266+ IEnumerable < SymbolReference > definitions = await GetDefinitions ( FindsVariableDefinitionData . SourceDetails ) . ConfigureAwait ( true ) ;
267+ SymbolReference symbol = Assert . Single ( definitions ) ; // Even though it's re-assigned
267268 Assert . Equal ( "var things" , symbol . Id ) ;
268269 Assert . Equal ( "$things" , symbol . Name ) ;
269270 Assert . Equal ( SymbolType . Variable , symbol . Type ) ;
You can’t perform that action at this time.
0 commit comments