File tree 3 files changed +12
-2
lines changed
src/PowerShellEditorServices/Services/Symbols
PowerShellEditorServices.Test/Language
PowerShellEditorServices.Test.Shared/References
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)
94
94
_ => new ConcurrentBag < SymbolReference > { symbol } ,
95
95
( _ , existing ) =>
96
96
{
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
+
97
106
existing . Add ( symbol ) ;
98
107
return existing ;
99
108
} ) ;
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ function My-Function ($myInput)
5
5
6
6
$things = 4
7
7
8
- $things
8
+ $things = 3
9
9
10
10
My- Function $things
11
11
Original file line number Diff line number Diff line change @@ -263,7 +263,8 @@ public async Task FindsFunctionDefinitionInWorkspace()
263
263
[ Fact ]
264
264
public async Task FindsVariableDefinition ( )
265
265
{
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
267
268
Assert . Equal ( "var things" , symbol . Id ) ;
268
269
Assert . Equal ( "$things" , symbol . Name ) ;
269
270
Assert . Equal ( SymbolType . Variable , symbol . Type ) ;
You can’t perform that action at this time.
0 commit comments