diff --git a/src/PowerShellEditorServices.Host/CodeLens/ReferencesCodeLensProvider.cs b/src/PowerShellEditorServices.Host/CodeLens/ReferencesCodeLensProvider.cs index 1fedc6cc5..bed4559a2 100644 --- a/src/PowerShellEditorServices.Host/CodeLens/ReferencesCodeLensProvider.cs +++ b/src/PowerShellEditorServices.Host/CodeLens/ReferencesCodeLensProvider.cs @@ -69,6 +69,7 @@ await editorSession.LanguageService.FindReferencesOfSymbol( ? new Location[0] : referencesResult .FoundReferences + .Where(r => NotReferenceDefinition(foundSymbol, r)) .Select( r => new Location { @@ -94,6 +95,16 @@ await editorSession.LanguageService.FindReferencesOfSymbol( )); } + private static bool NotReferenceDefinition( + SymbolReference definition, + SymbolReference reference) + { + return + definition.ScriptRegion.StartLineNumber != reference.ScriptRegion.StartLineNumber + || definition.SymbolType != reference.SymbolType + || !string.Equals(definition.SymbolName, reference.SymbolName, StringComparison.OrdinalIgnoreCase); + } + private static string GetFileUri(string filePath) { // If the file isn't untitled, return a URI-style path