@@ -92,17 +92,32 @@ private SearchResultsViewModel CreateViewModel(Declaration declaration)
92
92
private Declaration FindTarget ( object parameter )
93
93
{
94
94
var declaration = parameter as Declaration ;
95
- if ( declaration = = null )
95
+ if ( declaration ! = null )
96
96
{
97
- var selection = _vbe . ActiveCodePane . GetSelection ( ) ;
98
- if ( ! selection . Equals ( default ( QualifiedSelection ) ) )
99
- {
100
- declaration = _state . AllDeclarations
101
- . SingleOrDefault ( item => item . QualifiedSelection . Selection . ContainsFirstCharacter ( selection . Selection )
102
- || item . References . Any ( reference => reference . Selection . ContainsFirstCharacter ( selection . Selection ) ) ) ;
103
- }
97
+ return declaration ;
98
+ }
99
+
100
+ var selection = _vbe . ActiveCodePane . GetSelection ( ) ;
101
+ if ( ! selection . Equals ( default ( QualifiedSelection ) ) )
102
+ {
103
+ declaration = _state . AllDeclarations
104
+ . SingleOrDefault ( item =>
105
+ IsSelectedDeclaration ( selection , item ) ||
106
+ item . References . Any ( reference => IsSelectedReference ( selection , reference ) ) ) ;
104
107
}
105
108
return declaration ;
106
109
}
110
+
111
+ private static bool IsSelectedDeclaration ( QualifiedSelection selection , Declaration declaration )
112
+ {
113
+ return declaration . QualifiedSelection . QualifiedName . Equals ( selection . QualifiedName )
114
+ && declaration . QualifiedSelection . Selection . ContainsFirstCharacter ( selection . Selection ) ;
115
+ }
116
+
117
+ private static bool IsSelectedReference ( QualifiedSelection selection , IdentifierReference reference )
118
+ {
119
+ return reference . QualifiedModuleName . Equals ( selection . QualifiedName )
120
+ && reference . Selection . ContainsFirstCharacter ( selection . Selection ) ;
121
+ }
107
122
}
108
123
}
0 commit comments